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: Fix Go Static Check Errors #3637

Merged
merged 2 commits into from
Aug 5, 2023

Conversation

X-Guardian
Copy link
Contributor

@X-Guardian X-Guardian commented Jul 29, 2023

what

Fix the following Go static check errors:

{
	"resource": "server/events/github_app_working_dir_test.go",
	"message": "package \"github.com/petergtz/pegomock/v4\" is being imported more than once (ST1019)\n\tgithub_app_working_dir_test.go:8:2: other import of \"github.com/petergtz/pegomock/v4\"",
	"startLineNumber": 7,
},{
	"resource": "server/events/plan_command_runner_test.go",
	"message": "type RepoModel is unused (U1000)",
	"startLineNumber": 499,
},{
	"resource": "server/events/project_command_builder.go",
	"message": "*&x will be simplified to x. It will not copy x. (SA4001)",
	"startLineNumber": 737,
},{
	"resource": "server/events/project_command_context_builder.go",
	"message": "should omit comparison to bool constant, can be simplified to prjCfg.PolicyCheck (S1002)",
	"startLineNumber": 197,
},{
	"resource": "server/events/project_finder.go",
	"message": "pm.Matches is deprecated: This implementation is buggy (it only checks a single parent dir against the pattern) and will be removed soon. Use either MatchesOrParentMatches or MatchesUsingParentResults instead.  (SA1019)",
	"startLineNumber": 227,
	"startColumn": 18,
},{
	"resource": "server/events/project_finder.go",
	"message": "patternMatcher.Matches is deprecated: This implementation is buggy (it only checks a single parent dir against the pattern) and will be removed soon. Use either MatchesOrParentMatches or MatchesUsingParentResults instead.  (SA1019)",
	"startLineNumber": 269,
},{
	"resource": "server/events/working_dir_locker.go",
	"message": "error strings should not be capitalized (ST1005)",
	"startLineNumber": 66,
},{
	"resource": "server/events/working_dir_locker.go",
	"message": "error strings should not end with punctuation or newlines (ST1005)",
	"startLineNumber": 66,
},{
	"resource": "server/events/working_dir_locker.go",
	"severity": 4,
	"message": "error strings should not be capitalized (ST1005)",
	"startLineNumber": 85,
},{
	"resource": "server/events/working_dir_locker.go",
	"message": "error strings should not end with punctuation or newlines (ST1005)",
	"startLineNumber": 85,
}

Also fixed the working dir locker tests after the error string change.

why

Improve code quality

references

@X-Guardian X-Guardian requested a review from a team as a code owner July 29, 2023 12:48
@github-actions github-actions bot added go Pull requests that update Go code provider/github labels Jul 29, 2023
@jamengual
Copy link
Contributor

is the test error expected @X-Guardian ?

@X-Guardian
Copy link
Contributor Author

No @jamengual, I need to investigate whether there is an issue with one of these fixes, or whether they have exposed a bug.

@GenPage
Copy link
Member

GenPage commented Aug 3, 2023

The failure is due to the working_dir formatting changes:

--- FAIL: TestTryLock (0.00s)
working_dir_locker_test.go:36: exp err: "The default workspace at path . is currently locked by another command that is running for this pull request.
Wait until the previous command is complete and try again." 
but got: "the default workspace at path . is currently locked by another command that is running for this pull request.
Wait until the previous command is complete and try again"

@X-Guardian
Copy link
Contributor Author

Thanks @GenPage, I was assuming it was something more complex.

Test updated.

@GenPage GenPage enabled auto-merge (squash) August 5, 2023 20:41
Copy link
Member

@GenPage GenPage left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @X-Guardian, this was much needed

@GenPage GenPage merged commit ec77a95 into runatlantis:main Aug 5, 2023
@X-Guardian X-Guardian deleted the GoStaticCheckFix branch September 1, 2023 08:40
ijames-gc pushed a commit to gocardless/atlantis that referenced this pull request Feb 13, 2024
* Fix Go Static Checks

* Fix working dir tests
ijames-gc pushed a commit to gocardless/atlantis that referenced this pull request Feb 13, 2024
* Fix Go Static Checks

* Fix working dir tests
terakoya76 pushed a commit to terakoya76/atlantis that referenced this pull request Dec 31, 2024
* Fix Go Static Checks

* Fix working dir tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
go Pull requests that update Go code provider/github
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants