-
Notifications
You must be signed in to change notification settings - Fork 134
Upgrade golangci-lint to v2 #818
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
Conversation
| // - JobInsertMiddleware | ||
| // - WorkerMiddleware | ||
| // | ||
| // More operation-specific interfaces may be added in future versions. |
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.
These ones are a little unfortunate, but the lint that checks that comments end with periods has a bug in it where it was seeing "- WorkerMiddleware" as the last line, trying to rewrite it to end in a period with --fix, but then accidentally removing the entire comment in favor of just "- WorkerMiddleware." (period at end).
It's definitely a bug which I guess I should send over to someone, but it was just easier to add one more sentence at the end instead so it stops doing that.
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.
Wild bug. We could put the revert of this in its own branch and send it over as a reproduction if we know which repo to open it on?
7d3776c to
bff038a
Compare
bgentry
left a comment
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.
I'm a little nervous about shipping this in Pro prior to landing the next big PR there. Will try to get that finished up ASAP so it's a non-issue.
| - err113 # wants all errors to be defined as variables at the package level; quite obnoxious | ||
| - maintidx # ANOTHER ANOTHER "cyclomatic complexity" lint (see also "cyclop" and "gocyclo") | ||
| - mnd # detects "magic numbers", which it defines as any number; annoying | ||
| - nestif # yells when if blocks are nested; what planet do these people come from? |
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.
🤣
| - cyclop # screams into the void at "cyclomatic complexity" | ||
| - funlen # screams when functions are more than 60 lines long; what are we even doing here guys |
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.
These are popular in Ruby and Elixir. It makes a bit more sense in Ruby with DSLs and the low cost of extracting tons of little methods, but less so in Go IMO.
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.
Yeah exactly. IMO it seems fine to keep function lengths generally short, but requiring it of every single function is just too much. There are many places where a slightly longer function can be more clear than a shorter one! Dogma is the enemy quality.
.golangci.yaml
Outdated
| - pkg: github.com/xtgo/uuid | ||
| desc: Use `github.com/google/uuid` package for UUIDs instead. |
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.
intentional non-alphabetical resorts of attr ordering in here? There's a whole bunch of them.
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.
Ah yeah I didn't even notice.
I guess it doesn't matter as much for these sorts of two-item tuples, but just so we have a system, I put them all back the way they were including the Forbidigo rules below.
| } else if orderBy.Order == SortOrderDesc { | ||
| case SortOrderDesc: | ||
| orderByBuilder.WriteString(" DESC") | ||
| case SortOrderUnspecified: |
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.
Maybe this should actually be an 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.
Ah yeah, I wasn't sure if this was supposed to be possible or not.
I just replaced it with an error instead. Seems to pass the tests so hopefully it's okay ...
bff038a to
e386fb0
Compare
For better or rwose, golangci-lint has released a v2 [1] that's incompatible with v1. It'll only be a matter of time until we're forced to upgrade to it, so I figure we may as well do it early. There's a bunch of new obnoxious linters that I've disabled. Most of these complain about "cyclomatic complexity" or "cognitive complexity" or functions being too long (they all seem to want everything broken down into functions of ten lines). Aside from that, `testifylint` seems to have gotten even more effective at finding misuses of testify, so it fixed a bunch more arguable misuses of various assertions, which seems good for normalizing code. The structure of the YAML file changes fairly significantly, but it's all basically the same thing with various aspects reorganized. I made the new one using the built-in `golangci-lint migrate` and copied comments over manually. If we can get this in, the next step will be to distribute it out to other River projects. Most of them are using copies of this repo's configuration file, so it should be pretty easy to do. [1] https://ldez.github.io/blog/2025/03/23/golangci-lint-v2/
e386fb0 to
facf2ba
Compare
Golangci-lint v2 was released earlier this week [1]. The main River project has already been updated [2], so here we're just going through and updating all the peripheral projects as well. I'm reusing the same `.golangci.yaml` across all of them so that we stay reasonable standardized. [1] https://ldez.github.io/blog/2025/03/23/golangci-lint-v2/ [2] riverqueue/river#818
Golangci-lint v2 was released earlier this week [1]. The main River project has already been updated [2], so here we're just going through and updating all the peripheral projects as well. I'm reusing the same `.golangci.yaml` across all of them so that we stay reasonable standardized. [1] https://ldez.github.io/blog/2025/03/23/golangci-lint-v2/ [2] riverqueue/river#818
Golangci-lint v2 was released earlier this week [1]. The main River project has already been updated [2], so here we're just going through and updating all the peripheral projects as well. I'm reusing the same `.golangci.yaml` across all of them so that we stay reasonable standardized. [1] https://ldez.github.io/blog/2025/03/23/golangci-lint-v2/ [2] riverqueue/river#818
Golangci-lint v2 was released earlier this week [1]. The main River project has already been updated [2], so here we're just going through and updating all the peripheral projects as well. I'm reusing the same `.golangci.yaml` across all of them so that we stay reasonable standardized. [1] https://ldez.github.io/blog/2025/03/23/golangci-lint-v2/ [2] riverqueue/river#818
Golangci-lint v2 was released earlier this week [1]. The main River project has already been updated [2], so here we're just going through and updating all the peripheral projects as well. I'm reusing the same `.golangci.yaml` across all of them so that we stay reasonable standardized. [1] https://ldez.github.io/blog/2025/03/23/golangci-lint-v2/ [2] riverqueue/river#818
Golangci-lint v2 was released earlier this week [1]. The main River project has already been updated [2], so here we're just going through and updating all the peripheral projects as well. I'm reusing the same `.golangci.yaml` across all of them so that we stay reasonable standardized. [1] https://ldez.github.io/blog/2025/03/23/golangci-lint-v2/ [2] riverqueue/river#818
For better or rwose, golangci-lint has released a v2 [1] that's
incompatible with v1. It'll only be a matter of time until we're forced
to upgrade to it, so I figure we may as well do it early.
There's a bunch of new obnoxious linters that I've disabled. Most of
these complain about "cyclomatic complexity" or "cognitive complexity"
or functions being too long (they all seem to want everything broken
down into functions of ten lines).
Aside from that,
testifylintseems to have gotten even more effectiveat finding misuses of testify, so it fixed a bunch more arguable misuses
of various assertions, which seems good for normalizing code.
The structure of the YAML file changes fairly significantly, but it's
all basically the same thing with various aspects reorganized. I made
the new one using the built-in
golangci-lint migrateand copiedcomments over manually.
If we can get this in, the next step will be to distribute it out to
other River projects. Most of them are using copies of this repo's
configuration file, so it should be pretty easy to do.
[1] https://ldez.github.io/blog/2025/03/23/golangci-lint-v2/