chore: bump golangci-lint to v2#49870
Conversation
7e3d641 to
f502b2e
Compare
b5c4481 to
2935a98
Compare
fe97b2d to
e25d087
Compare
| checks: | ||
| - all | ||
| - -QF1001 # FIXME: Apply De Morgan’s law | ||
| - -QF1003 # FIXME: Convert if/else-if chain to tagged switch | ||
| - -QF1004 # FIXME: Use strings.ReplaceAll instead of strings.Replace with n == -1 | ||
| - -QF1006 # FIXME: Lift if+break into loop condition | ||
| - -QF1007 # FIXME: Merge conditional assignment into variable declaration | ||
| - -QF1008 # FIXME: Omit embedded fields from selector expression | ||
| - -QF1011 # FIXME: Omit redundant type from variable declaration | ||
| - -QF1012 # FIXME: Use fmt.Fprintf(x, ...) instead of x.Write(fmt.Sprintf(...)) | ||
| - -S1000 # FIXME: Use plain channel send or receive instead of single-case select | ||
| - -SA4006 # FIXME: A value assigned to a variable is never read before being overwritten. Forgotten error check or dead code? | ||
| - -ST1000 # FIXME: Incorrect or missing package comment | ||
| - -ST1003 # FIXME: Poorly chosen identifier | ||
| - -ST1005 # FIXME: Incorrectly formatted error string | ||
| - -ST1006 # FIXME: Poorly chosen receiver name | ||
| - -ST1015 # FIXME: A switch’s default case should be the first or last case | ||
| - -ST1016 # FIXME: Use consistent method receiver names | ||
| - -ST1017 # FIXME: Don’t use Yoda conditions | ||
| - -ST1019 # FIXME: Importing the same package multiple times | ||
| - -ST1020 # FIXME: The documentation of an exported function should start with the function’s name | ||
| - -ST1023 # FIXME: Redundant type in variable declaration | ||
|
|
There was a problem hiding this comment.
I recall there were at least 2 that we prefer not to enable; see https://github.com/moby/sys/blob/c9593b2d4e2ac2478a7d1e1cdaa08436a89ca079/.golangci.yml#L14-L20
Specifically QF1008 was too opinionated to apply as a general rule; see moby/sys#187 (comment)
There was a problem hiding this comment.
What do you expect me to do here, just remove the FIXME part and keep the documentation part ?
There was a problem hiding this comment.
Sorry, I was a bit brief, as I had to head out.
Yes, we should probably put those as "permanent" (without a "fixme"). That's not to say we won't revisit its suggestions where it makes sense, but those were a bit too opinionated to be used as a strict requirement.
As to our usual flow for these (none of this is a "hard rule", just a flow that worked well before)
- Where possible, we make the changes to make the linters happy first; usually that's in a separate PR (or a couple PR's, depending).
- Reason there is that in most cases, such fixes already apply, just that older linters may not have detected them.
- Of course there's exceptions; sometimes newer linters became more "relaxed" (so some "nolint" comments becoming redundant); those can go in together with the PR that updates the linters, if removing them ahead of time would cause CI to fail).
- 👆if there's many changes, I usually try to keep them in smaller commits (sometimes grouped by package), which can help if such changes would have to be backported to a release branch.
- If there's new rules that result in an exceptionally large number of issues; for those it may indeed be good to add a global exclude, and depending on the changes, perhaps a tracking ticket (for cases where the linter is "correct", but the issues non critical, or requiring further investigation or discussion)
- Depending on that discussion, we can decide to make an exception "permanent" (won't fix)
After the linting fixes are merged (which allows us to verify they look good, also on older linters), we can update the linters (that PR would only contain the updates required for updating the linter)
There was a problem hiding this comment.
I opened #49885
what is left concerning staticcheck would be
staticcheck:
checks:
- all
- -QF1008 # Omit embedded fields from selector expression
- -S1000 # Use plain channel send or receive instead of single-case select
- -SA4006 # A value assigned to a variable is never read before being overwritten. Forgotten error check or dead code?
- -SA5011 # Possible nil pointer dereference
- -ST1000 # Incorrect or missing package comment
- -ST1003 # Poorly chosen identifier
- -ST1005 # Incorrectly formatted error string
- -ST1020 # The documentation of an exported function should start with the function’s nameb22b03c to
48ac841
Compare
ef25ccb to
ecfa581
Compare
a622d4c to
900cc9c
Compare
|
Do you believe #49920 shall be adressed first to be able to enable nakedret ? |
If it's easy to add an exception for the files it hits (a temporary filter on path?) I'd be fine with keeping that as a follow-up; I'll see if others could have an eye on those changes. |
| checks: | ||
| - all | ||
| - -QF1008 # Omit embedded fields from selector expression; https://staticcheck.dev/docs/checks/#QF1008 | ||
| - -S1000 # Use plain channel send or receive instead of single-case select; https://staticcheck.dev/docs/checks/#S1000 |
There was a problem hiding this comment.
Looks like this one is only hit in a single location, which may be fixable, but probably fine for a follow-up (or I may have a quick look)
There was a problem hiding this comment.
☝️ I'm OK with addressing this one in a follow up if I didn't find time to look at the correct patch.
c2a5900 to
b6afa35
Compare
thaJeztah
left a comment
There was a problem hiding this comment.
LGTM after the two redundant exclusions are removed (assuming CI is happy with that)
b6afa35 to
c33d58a
Compare
|
ST1005 has 158 issues, it is probably better to adress it later ? |
c33d58a to
40e8fc8
Compare
|
Oh! Looks like my comment landed on the wrong line? 🙈 |
40e8fc8 to
5a74f75
Compare
Signed-off-by: Matthieu MOREL <[email protected]>
5a74f75 to
7b5d2b4
Compare
- What I did
bump golangci-lint to v2
- How I did it
use golangci-lint migrate from migration-guide and realign the result to make it as close as possible as the actual configuration
- How to verify it
Golangci-lint is still working and raising proper issues.
- Human readable description for the release notes
- A picture of a cute animal (not mandatory but encouraged)
No