-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
🌱 Enable excluded lint checks #4624
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,10 +38,21 @@ linters: | |
issues: | ||
max-same-issues: 0 | ||
max-issues-per-linter: 0 | ||
# We are disabling default golangci exclusions because we want to help reviewers to focus on reviewing the most relevant | ||
# changes in PRs and avoid nitpicking. | ||
exclude-use-default: false | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What about adding a comment here:
|
||
# List of regexps of issue texts to exclude, empty list by default. | ||
exclude: | ||
- Using the variable on range scope `(tc)|(rt)|(tt)|(test)|(testcase)|(testCase)` in function literal | ||
- "G108: Profiling endpoint is automatically exposed on /debug/pprof" | ||
- Error return value of .((os\.)?std(out|err)\..*|.*Close|.*Flush|os\.Remove(All)?|.*print(f|ln)?|os\.(Un)?Setenv). is not checked | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wonder if we want to get rid of a few of them. not the ones about There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As mentioned above, file.Close() in a defer is actually useful. While ignoring the error can be odd, if a file cannot be closed (because it's a syscall) an error is usually thrown way earlier. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Okay, missed your comment above. Then it's fine for me. Just had a few of those when close failed when writing to S3/GCS and it's pretty hard to debug. But we also have "manual" reviews, so we should be good |
||
# The following are being worked on to remove their exclusion. This list should be reduced or go away all together over time. | ||
# If it is decided they will not be addressed they should be moved above this comment. | ||
- (comment on exported (method|function|type|const)|should have( a package)? comment|comment should be of the form) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @stmcginnis That's the one which would detect these kinds of error right? https://github.com/kubernetes-sigs/cluster-api/pull/4607/files There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yep, I believe so. Next in the list to tackle. ;) |
||
- package comment should be of the form "Package (.+) ..." | ||
stmcginnis marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- Subprocess launch(ed with variable|ing should be audited) | ||
- (Expect directory permissions to be 0750 or less|Expect file permissions to be 0600 or less) | ||
- (G104|G307) | ||
vincepri marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
run: | ||
timeout: 10m | ||
|
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.
Some additional ideas for linters:
goimports --local
) (if we want that)ref: https://golangci-lint.run/usage/linters/
Just some ideas. I don't want to start a lengthy discussion like tab vs spaces :). But if we get consensus on one / a few of them, that would be nice.
If we want them, they should probably be added commented out here and then introduced one at a time (like with the
exclude
below)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.
+1 on exportloopref, ifshort, and nilerr
The others require new tooling that are more stylistic than not, which I'm generally fine to leave as is