Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(atlantis): fix linter errors #3690

Merged
merged 14 commits into from
Dec 11, 2023

Conversation

GMartinez-Sisti
Copy link
Member

@GMartinez-Sisti GMartinez-Sisti commented Aug 21, 2023

what

  • Following the discussion on slack, this PR fixes the linter errors
  • These errors were most likely introduced with this PR on v1.3.0 and will mostly happen to new comers when they run the linter and the latest revive version is installed
  • Make the CI lint job fail on error (it's failing silently on all PRs) Removed due to complaint

why

  • Ensure the linter is trustworthy

tests

Tested using make lint.

Result before PR
golangci-lint run
server/events/apply_command_runner_test.go:1: : # github.com/runatlantis/atlantis/server/events_test [github.com/runatlantis/atlantis/server/events.test]
server/events/event_parser_test.go:49:35: cannot use &Repo (value of type *"github.com/google/go-github/v53/github".Repository) as *"github.com/google/go-github/v54/github".Repository value in argument to parser.ParseGithubRepo
server/events/event_parser_test.go:66:9: cannot use &Repo (value of type *"github.com/google/go-github/v53/github".Repository) as *"github.com/google/go-github/v54/github".Repository value in struct literal
server/events/event_parser_test.go:136:89: cannot use &PullEvent (value of type *"github.com/google/go-github/v53/github".PullRequestEvent) as *"github.com/google/go-github/v54/github".PullRequestEvent value in argument to parser.ParseGithubPullEvent
server/events/event_parser_test.go:307:67: cannot use &Pull (value of type *"github.com/google/go-github/v53/github".PullRequest) as *"github.com/google/go-github/v54/github".PullRequest value in argument to parser.ParseGithubPull (typecheck)
package events_test
server/events/vcs/gitlab_client_test.go:414:33: Error return value of `(*encoding/json.Encoder).Encode` is not checked (errcheck)
							json.NewEncoder(w).Encode(v)
							                         ^
server/events/vcs/gitlab_client_test.go:525:36: Error return value of `(*encoding/json.Decoder).Decode` is not checked (errcheck)
					json.NewDecoder(r.Body).Decode(&body)
					                              ^
server/core/config/raw/step.go:40: File is not `gofmt`-ed with `-s` (gofmt)
//       name: test
//       command: echo 312
//       value: value
server/jobs/project_command_output_handler.go:270:41: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive)
func (p *NoopProjectOutputHandler) Send(ctx command.ProjectContext, msg string, isOperationComplete bool) {
                                        ^
server/jobs/project_command_output_handler.go:273:53: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive)
func (p *NoopProjectOutputHandler) SendWorkflowHook(ctx models.WorkflowHookCommandContext, msg string, operationComplete bool) {
                                                    ^
server/jobs/project_command_output_handler.go:276:45: unused-parameter: parameter 'jobID' seems to be unused, consider removing or renaming it as _ (revive)
func (p *NoopProjectOutputHandler) Register(jobID string, receiver chan string)   {}
                                            ^
server/jobs/project_command_output_handler.go:277:47: unused-parameter: parameter 'jobID' seems to be unused, consider removing or renaming it as _ (revive)
func (p *NoopProjectOutputHandler) Deregister(jobID string, receiver chan string) {}
                                              ^
server/jobs/project_command_output_handler.go:282:44: unused-parameter: parameter 'pullInfo' seems to be unused, consider removing or renaming it as _ (revive)
func (p *NoopProjectOutputHandler) CleanUp(pullInfo PullInfo) {
                                           ^
server/jobs/project_command_output_handler.go:285:48: unused-parameter: parameter 'key' seems to be unused, consider removing or renaming it as _ (revive)
func (p *NoopProjectOutputHandler) IsKeyExists(key string) bool {
                                               ^
server/events/webhooks/slack.go:44:29: unused-parameter: parameter 'log' seems to be unused, consider removing or renaming it as _ (revive)
func (s *SlackWebhook) Send(log logging.SimpleLogging, applyResult ApplyResult) error {
                            ^
server/core/locking/locking.go:169:66: unused-parameter: parameter 'pull' seems to be unused, consider removing or renaming it as _ (revive)
func (c *NoOpLocker) TryLock(p models.Project, workspace string, pull models.PullRequest, user models.User) (TryLockResponse, error) {
                                                                 ^
server/core/locking/locking.go:177:29: unused-parameter: parameter 'key' seems to be unused, consider removing or renaming it as _ (revive)
func (c *NoOpLocker) Unlock(key string) (*models.ProjectLock, error) {
                            ^
server/core/locking/locking.go:189:35: unused-parameter: parameter 'repoFullName' seems to be unused, consider removing or renaming it as _ (revive)
func (c *NoOpLocker) UnlockByPull(repoFullName string, pullNum int) ([]models.ProjectLock, error) {
                                  ^
server/core/locking/locking.go:197:30: unused-parameter: parameter 'key' seems to be unused, consider removing or renaming it as _ (revive)
func (c *NoOpLocker) GetLock(key string) (*models.ProjectLock, error) {
                             ^
server/core/redis/redis.go:59:42: unused-parameter: parameter 'bucket' seems to be unused, consider removing or renaming it as _ (revive)
func NewWithClient(client *redis.Client, bucket string, globalBucket string) (*RedisDB, error) {
                                         ^
server/jobs/project_command_output_handler_test.go:194:4: empty-block: this block is empty, you can remove it (revive)
			for range ch {
			}
server/jobs/project_command_output_handler_test.go:228:4: empty-block: this block is empty, you can remove it (revive)
			for range ch {
			}
server/jobs/project_command_output_handler_test.go:243:4: empty-block: this block is empty, you can remove it (revive)
			for range ch2 {
			}
server/core/db/boltdb_test.go:289:2: redefines-builtin-id: redefinition of the built-in function new (revive)
	new := lock
	^
server/core/db/boltdb_test.go:386:2: redefines-builtin-id: redefinition of the built-in function new (revive)
	new := lock
	^
server/events/vcs/bitbucketcloud/client.go:88:79: unused-parameter: parameter 'command' seems to be unused, consider removing or renaming it as _ (revive)
func (b *Client) CreateComment(repo models.Repo, pullNum int, comment string, command string) error {
                                                                              ^
server/events/vcs/bitbucketcloud/client.go:109:42: unused-parameter: parameter 'repo' seems to be unused, consider removing or renaming it as _ (revive)
func (b *Client) HidePrevCommandComments(repo models.Repo, pullNum int, command string) error {
                                         ^
server/events/vcs/bitbucketcloud/client.go:141:77: unused-parameter: parameter 'vcsstatusname' seems to be unused, consider removing or renaming it as _ (revive)
func (b *Client) PullIsMergeable(repo models.Repo, pull models.PullRequest, vcsstatusname string) (bool, error) {
                                                                            ^
server/events/vcs/bitbucketcloud/client.go:210:53: unused-parameter: parameter 'pullOptions' seems to be unused, consider removing or renaming it as _ (revive)
func (b *Client) MergePull(pull models.PullRequest, pullOptions models.PullRequestOptions) error {
                                                    ^
server/events/vcs/bitbucketcloud/client.go:237:33: unused-parameter: parameter 'repo' seems to be unused, consider removing or renaming it as _ (revive)
func (b *Client) DiscardReviews(repo models.Repo, pull models.PullRequest) error {
                                ^
server/events/vcs/bitbucketcloud/client.go:266:38: unused-parameter: parameter 'repo' seems to be unused, consider removing or renaming it as _ (revive)
func (b *Client) GetTeamNamesForUser(repo models.Repo, user models.User) ([]string, error) {
                                     ^
server/events/vcs/bitbucketcloud/client.go:277:33: unused-parameter: parameter 'pull' seems to be unused, consider removing or renaming it as _ (revive)
func (b *Client) GetFileContent(pull models.PullRequest, fileName string) (bool, []byte, error) {
                                ^
server/events/vcs/bitbucketcloud/client.go:281:30: unused-parameter: parameter 'VCSHostType' seems to be unused, consider removing or renaming it as _ (revive)
func (b *Client) GetCloneURL(VCSHostType models.VCSHostType, repo string) (string, error) {
                             ^
server/core/runtime/version_step_runner.go:17:61: unused-parameter: parameter 'extraArgs' seems to be unused, consider removing or renaming it as _ (revive)
func (v *VersionStepRunner) Run(ctx command.ProjectContext, extraArgs []string, path string, envs map[string]string) (string, error) {
                                                            ^
server/core/runtime/show_step_runner.go:30:58: unused-parameter: parameter 'extraArgs' seems to be unused, consider removing or renaming it as _ (revive)
func (p *showStepRunner) Run(ctx command.ProjectContext, extraArgs []string, path string, envs map[string]string) (string, error) {
                                                         ^
server/core/runtime/runtime.go:67:53: unused-parameter: parameter 'extraArgs' seems to be unused, consider removing or renaming it as _ (revive)
func (p NullRunner) Run(ctx command.ProjectContext, extraArgs []string, path string, envs map[string]string) (string, error) {
                                                    ^
server/core/runtime/apply_step_runner_test.go:364:43: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive)
func (r *remoteApplyMock) RunCommandAsync(ctx command.ProjectContext, path string, args []string, envs map[string]string, v *version.Version, workspace string) (chan<- string, <-chan runtimemodels.Line) {
                                          ^
server/events/vcs/bitbucketserver/client.go:136:79: unused-parameter: parameter 'command' seems to be unused, consider removing or renaming it as _ (revive)
func (b *Client) CreateComment(repo models.Repo, pullNum int, comment string, command string) error {
                                                                              ^
server/events/vcs/bitbucketserver/client.go:205:77: unused-parameter: parameter 'vcsstatusname' seems to be unused, consider removing or renaming it as _ (revive)
func (b *Client) PullIsMergeable(repo models.Repo, pull models.PullRequest, vcsstatusname string) (bool, error) {
                                                                            ^
server/events/vcs/bitbucketserver/client.go:361:33: unused-parameter: parameter 'pull' seems to be unused, consider removing or renaming it as _ (revive)
func (b *Client) GetFileContent(pull models.PullRequest, fileName string) (bool, []byte, error) {
                                ^
server/events/vcs/bitbucketserver/client.go:365:30: unused-parameter: parameter 'VCSHostType' seems to be unused, consider removing or renaming it as _ (revive)
func (b *Client) GetCloneURL(VCSHostType models.VCSHostType, repo string) (string, error) {
                             ^
server/controllers/status_controller.go:26:55: unused-parameter: parameter 'r' seems to be unused, consider removing or renaming it as _ (revive)
func (d *StatusController) Get(w http.ResponseWriter, r *http.Request) {
                                                      ^
server/controllers/github_app_controller.go:88:58: unused-parameter: parameter 'r' seems to be unused, consider removing or renaming it as _ (revive)
func (g *GithubAppController) New(w http.ResponseWriter, r *http.Request) {
                                                         ^
server/controllers/locks_controller.go:35:60: unused-parameter: parameter 'r' seems to be unused, consider removing or renaming it as _ (revive)
func (l *LocksController) LockApply(w http.ResponseWriter, r *http.Request) {
                                                           ^
server/events/vcs/gitlab_client.go:173:85: unused-parameter: parameter 'command' seems to be unused, consider removing or renaming it as _ (revive)
func (g *GitlabClient) CreateComment(repo models.Repo, pullNum int, comment string, command string) error {
                                                                                    ^
server/events/vcs/gitlab_client.go:511:36: unused-parameter: parameter 'VCSHostType' seems to be unused, consider removing or renaming it as _ (revive)
func (g *GitlabClient) GetCloneURL(VCSHostType models.VCSHostType, repo string) (string, error) {
                                   ^
server/events/vcs/github_client.go:202:57: unused-parameter: parameter 'pullNum' seems to be unused, consider removing or renaming it as _ (revive)
func (g *GithubClient) ReactToComment(repo models.Repo, pullNum int, commentID int64, reaction string) error {
                                                        ^
server/events/vcs/github_client.go:585:59: unused-parameter: parameter 'pullOptions' seems to be unused, consider removing or renaming it as _ (revive)
func (g *GithubClient) MergePull(pull models.PullRequest, pullOptions models.PullRequestOptions) error {
                                                          ^
server/events/vcs/azuredevops_client.go:179:88: unused-parameter: parameter 'vcsstatusname' seems to be unused, consider removing or renaming it as _ (revive)
func (g *AzureDevopsClient) PullIsMergeable(repo models.Repo, pull models.PullRequest, vcsstatusname string) (bool, error) {
                                                                                       ^
server/events/vcs/github_client.go:445:13: superfluous-else: if block ends with a continue statement, so drop this else and outdent its block (revive)
					} else {
						return false, nil
					}
server/events/vcs/gitlab_client_test.go:128:7: increment-decrement: should replace numAttempts += 1 with numAttempts++ (revive)
						numAttempts += 1
						^
server/events/vcs/gitlab_client_test.go:332:3: var-naming: struct field mrId should be mrID (revive)
		mrId          int
		^
server/events/event_parser.go:602:9: indent-error-flow: if block ends with a return statement, so drop this else and outdent its block (revive)
	} else {
		return models.OtherPullEvent
	}
server/events/command_runner.go:364:2: unused-parameter: parameter 'user' seems to be unused, consider removing or renaming it as _ (revive)
	user models.User,
	^
server/events/unlock_command_runner.go:30:2: unused-parameter: parameter 'cmd' seems to be unused, consider removing or renaming it as _ (revive)
	cmd *CommentCommand,
	^
server/events/project_command_builder.go:115:2: unused-parameter: parameter 'logger' seems to be unused, consider removing or renaming it as _ (revive)
	logger logging.SimpleLogging,
	^
server/core/redis/redis_test.go:325:2: redefines-builtin-id: redefinition of the built-in function new (revive)
	new := lock
	^
cmd/server_test.go:41:69: unused-parameter: parameter 'config' seems to be unused, consider removing or renaming it as _ (revive)
func (s *ServerCreatorMock) NewServer(userConfig server.UserConfig, config server.Config) (ServerStarter, error) {
                                                                    ^
server/core/config/raw/global_cfg.go:283:77: S1002: should omit comparison to bool constant, can be simplified to `!*r.PolicyCheck` (gosimple)
		if globalReq == valid.PoliciesPassedCommandReq && r.PolicyCheck != nil && *r.PolicyCheck == false {
		                                                                          ^
server/core/config/raw/global_cfg.go:297:77: S1002: should omit comparison to bool constant, can be simplified to `!*r.PolicyCheck` (gosimple)
		if globalReq == valid.PoliciesPassedCommandReq && r.PolicyCheck != nil && *r.PolicyCheck == false {
		                                                                          ^
server/core/config/raw/global_cfg.go:311:77: S1002: should omit comparison to bool constant, can be simplified to `!*r.PolicyCheck` (gosimple)
		if globalReq == valid.PoliciesPassedCommandReq && r.PolicyCheck != nil && *r.PolicyCheck == false {
		                                                                          ^
server/events/vcs/gitlab_client.go:322:11: SA1019: mr.MergeStatus is deprecated: This parameter is replaced by DetailedMergeStatus in GitLab 15.6. (staticcheck)
		(!ok && mr.MergeStatus == "can_be_merged")) &&
		        ^

@GMartinez-Sisti
Copy link
Member Author

@nitrocode comments addressed.

@GMartinez-Sisti
Copy link
Member Author

Resolved conflict.

.github/workflows/lint.yml Outdated Show resolved Hide resolved
.github/workflows/lint.yml Outdated Show resolved Hide resolved
server/core/runtime/plan_step_runner_test.go Show resolved Hide resolved
@github-actions
Copy link

This issue is stale because it has been open for 1 month with no activity. Remove stale label or comment or this will be closed in 1 month.

Copy link

This issue is stale because it has been open for 1 month with no activity. Remove stale label or comment or this will be closed in 1 month.

@github-actions github-actions bot added the Stale label Nov 14, 2023
@GMartinez-Sisti
Copy link
Member Author

Merged main again.

@github-actions github-actions bot removed the Stale label Nov 15, 2023
@jamengual jamengual added waiting-on-review Waiting for a review from a maintainer and removed waiting-on-response Waiting for a response from the user labels Nov 15, 2023
@GMartinez-Sisti
Copy link
Member Author

All fixed 🥳

Click to expand result.
gabrielmartinez @ ~/Git/Misc/atlantis (fix-linters =) → git log -n 1
commit 86fd0e76ad216055bd4498b1b5b74e43895534cc (HEAD -> fix-linters, origin/fix-linters)
Author: Gabriel Martinez <[email protected]>
Date:   Sun Dec 10 12:46:41 2023 +0000

    more lint fixes

gabrielmartinez @ ~/Git/Misc/atlantis (fix-linters =) → make lint
golangci-lint run

gabrielmartinez @ ~/Git/Misc/atlantis (fix-linters =) → make test-all
?       github.com/runatlantis/atlantis [no test files]
ok      github.com/runatlantis/atlantis/cmd     0.635s
ok      github.com/runatlantis/atlantis/server  1.292s
ok      github.com/runatlantis/atlantis/server/controllers      0.652s
?       github.com/runatlantis/atlantis/testdrive       [no test files]
ok      github.com/runatlantis/atlantis/server/controllers/events       263.081s
ok      github.com/runatlantis/atlantis/server/controllers/templates    1.469s
ok      github.com/runatlantis/atlantis/server/controllers/websocket    1.109s
ok      github.com/runatlantis/atlantis/server/core/config      1.062s
ok      github.com/runatlantis/atlantis/server/core/config/raw  0.673s
ok      github.com/runatlantis/atlantis/server/core/config/valid        0.402s
ok      github.com/runatlantis/atlantis/server/core/db  1.332s
ok      github.com/runatlantis/atlantis/server/core/locking     0.498s
ok      github.com/runatlantis/atlantis/server/core/redis       0.727s
ok      github.com/runatlantis/atlantis/server/core/runtime     3.486s
ok      github.com/runatlantis/atlantis/server/core/runtime/cache       0.237s
ok      github.com/runatlantis/atlantis/server/core/runtime/common      2.787s
ok      github.com/runatlantis/atlantis/server/core/runtime/models      0.464s
ok      github.com/runatlantis/atlantis/server/core/runtime/policy      0.424s
ok      github.com/runatlantis/atlantis/server/core/terraform   5.867s
ok      github.com/runatlantis/atlantis/server/events   25.763s
ok      github.com/runatlantis/atlantis/server/events/command   0.331s
ok      github.com/runatlantis/atlantis/server/events/models    0.949s
ok      github.com/runatlantis/atlantis/server/events/terraform/ansi    0.242s
ok      github.com/runatlantis/atlantis/server/events/vcs       9.556s
ok      github.com/runatlantis/atlantis/server/events/vcs/bitbucketcloud        0.377s
ok      github.com/runatlantis/atlantis/server/events/vcs/bitbucketserver       0.855s
ok      github.com/runatlantis/atlantis/server/events/vcs/common        0.269s
ok      github.com/runatlantis/atlantis/server/events/webhooks  0.342s
ok      github.com/runatlantis/atlantis/server/jobs     0.355s
ok      github.com/runatlantis/atlantis/server/logging  0.263s
ok      github.com/runatlantis/atlantis/server/metrics  0.292s
ok      github.com/runatlantis/atlantis/server/recovery 0.236s
ok      github.com/runatlantis/atlantis/server/scheduled        1.261s
ok      github.com/runatlantis/atlantis/server/utils    0.434s

@GenPage GenPage enabled auto-merge (squash) December 11, 2023 18:45
@GenPage GenPage added this to the v0.27.0 milestone Dec 11, 2023
@GenPage GenPage merged commit 56e38b4 into runatlantis:main Dec 11, 2023
24 checks passed
@GMartinez-Sisti GMartinez-Sisti deleted the fix-linters branch December 11, 2023 19:36
cypres added a commit to cypres/atlantis that referenced this pull request Jan 23, 2024
Reverts linter change from runatlantis#3690 which breaks TF v1.1 detection
cypres added a commit to cypres/atlantis that referenced this pull request Jan 23, 2024
Reverts linter change from runatlantis#3690 which breaks TF v1.1 detection
ijames-gc pushed a commit to gocardless/atlantis that referenced this pull request Feb 13, 2024
* chore(atlantis): fix linter errors

* fix superfluous-else

* revert gitlab check

* ignore stub funcs on azuredevops_client

* remove fetch-depth

* remove fail_on_error

* fix plan_step_runner_test.go

* more lint fixes

---------

Co-authored-by: Dylan Page <[email protected]>
ijames-gc pushed a commit to gocardless/atlantis that referenced this pull request Feb 13, 2024
* chore(atlantis): fix linter errors

* fix superfluous-else

* revert gitlab check

* ignore stub funcs on azuredevops_client

* remove fetch-depth

* remove fail_on_error

* fix plan_step_runner_test.go

* more lint fixes

---------

Co-authored-by: Dylan Page <[email protected]>
GenPage pushed a commit that referenced this pull request Mar 5, 2024
Reverts linter change from #3690 which breaks TF v1.1 detection
gcp-cherry-pick-bot bot pushed a commit that referenced this pull request Mar 8, 2024
Reverts linter change from #3690 which breaks TF v1.1 detection
GenPage pushed a commit that referenced this pull request Mar 8, 2024
Reverts linter change from #3690 which breaks TF v1.1 detection

Co-authored-by: Hans Arnholm <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working go Pull requests that update Go code provider/azuredevops provider/bitbucket provider/github provider/gitlab waiting-on-review Waiting for a review from a maintainer work-in-progress
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants