-
Notifications
You must be signed in to change notification settings - Fork 502
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
Apply first batch of golangci linters #948
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@saschagrunert -- Linting makes me happy! :)
I've got a few comments for clarification and one nit before approving.
Also, for future PRs, can we have one commit per linter enabled?
e.g.,:
lint: Enable golang `errcheck` linter
This will make it really easy to back out of any potential breaking changes.
/hold
@@ -106,6 +105,7 @@ linters-settings: | |||
- valSwap | |||
- wrapperFunc | |||
- yodaStyleExpr | |||
# - ifElseChain |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason we commented this one out when it was uncommented before?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It reports to refactor else-if chains into switch statements, like:
Lines 111 to 122 in af8e773
if err == nil { | |
// The file or directory exists, just try to update the repo | |
return updateRepo(repoPath, useSSH) | |
} else if os.IsNotExist(err) { | |
// The directory does not exists, we still have to clone it | |
targetDir = repoPath | |
} else { | |
// Something else bad happened | |
return nil, err | |
} |
I'm not sure if we should do this and I tend to say no. But I'm open to go with the defaults.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's leave that one commented out for now.
I'd say once we hit three or more chains and there's a common pattern, maybe consider switch
statements, but I don't think we need to nit on it at the moment.
@@ -57,19 +55,3 @@ func init() { | |||
// initConfig reads in config file and ENV variables if set. | |||
func initConfig() { | |||
} | |||
|
|||
func cleanupTmpDir(dir string) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
deadcode
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I could also add a nolint
if we will need it in the future. Right now the git package takes care of that cleanup.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We'll need a common cleanup function somewhere, that is separate from the git package.
So this is fine right now, but we'll need to address that in a follow-up.
/assign |
Yeah I thought the same after I opened the PR, sorry for that 😇 |
We enable and fix the reports of the following linters: - deadcode - gocritic - golint - ineffassign - maligned - prealloc - staticcheck - unparam - unused - whitepsace Signed-off-by: Sascha Grunert <[email protected]>
Thanks again, Sascha! |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: justaugustus, saschagrunert The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
We enable and fix the reports of the following linters: