-
Notifications
You must be signed in to change notification settings - Fork 150
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
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 |
|---|---|---|
| @@ -1,16 +1,7 @@ | ||
| issues: | ||
| exclude: | ||
| - 'Error return value of .(\w+\.Rollback(.*)). is not checked' | ||
| version: "2" | ||
|
|
||
| linters: | ||
| presets: | ||
| - bugs | ||
| - comment | ||
| - format | ||
| - performance | ||
| - style | ||
| - test | ||
| - unused | ||
| default: all | ||
|
|
||
| disable: | ||
| # disabled, but which we should enable with discussion | ||
|
|
@@ -21,82 +12,109 @@ linters: | |
| - testpackage # requires tests in test packages like `river_test` | ||
|
|
||
| # disabled because they're annoying/bad | ||
| - 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 | ||
| - interfacebloat # we do in fact want >10 methods on the Adapter interface or wherever we see fit. | ||
| - gocognit # yells that "cognitive complexity" is too high; why | ||
| - gocyclo # ANOTHER "cyclomatic complexity" checker (see also "cyclop" and "gocyclo") | ||
| - godox # bans TODO statements; total non-starter at the moment | ||
| - 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? | ||
|
Contributor
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. 🤣 |
||
| - ireturn # bans returning interfaces; questionable as is, but also buggy as hell; very, very annoying | ||
| - lll # restricts maximum line length; annoying | ||
| - nlreturn # requires a blank line before returns; annoying | ||
| - wsl # a bunch of style/whitespace stuff; annoying | ||
|
|
||
| linters-settings: | ||
| depguard: | ||
| rules: | ||
| all: | ||
| files: ["$all"] | ||
| allow: | ||
| deny: | ||
| - desc: "Use `github.com/google/uuid` package for UUIDs instead." | ||
| pkg: "github.com/xtgo/uuid" | ||
| not-test: | ||
| files: ["!$test"] | ||
| deny: | ||
| - desc: "Don't use `dbadaptertest` package outside of test environments." | ||
| pkg: "github.com/riverqueue/river/internal/dbadaptertest" | ||
| - desc: "Don't use `riverinternaltest` package outside of test environments." | ||
| pkg: "github.com/riverqueue/river/internal/riverinternaltest" | ||
| settings: | ||
| depguard: | ||
| rules: | ||
| all: | ||
| files: ["$all"] | ||
| deny: | ||
| - desc: Use `github.com/google/uuid` package for UUIDs instead. | ||
| pkg: github.com/xtgo/uuid | ||
| not-test: | ||
| files: ["!$test"] | ||
| deny: | ||
| - desc: Don't use `dbadaptertest` package outside of test environments. | ||
| pkg: github.com/riverqueue/river/internal/dbadaptertest | ||
| - desc: Don't use `riverinternaltest` package outside of test environments. | ||
| pkg: github.com/riverqueue/river/internal/riverinternaltest | ||
|
|
||
| forbidigo: | ||
| forbid: | ||
| - msg: "Use `require` variants instead." | ||
| p: '^assert\.' | ||
| - msg: "Use `Func` suffix for function variables instead." | ||
| p: 'Fn\b' | ||
| - msg: "Use built-in `max` function instead." | ||
| p: '\bmath\.Max\b' | ||
| - msg: "Use built-in `min` function instead." | ||
| p: '\bmath\.Min\b' | ||
| forbidigo: | ||
| forbid: | ||
| - msg: Use `require` variants instead. | ||
| pattern: ^assert\. | ||
| - msg: Use `Func` suffix for function variables instead. | ||
| pattern: Fn\b | ||
| - msg: Use built-in `max` function instead. | ||
| pattern: \bmath\.Max\b | ||
| - msg: Use built-in `min` function instead. | ||
| pattern: \bmath\.Min\b | ||
|
|
||
| gci: | ||
| sections: | ||
| - Standard | ||
| - Default | ||
| - Prefix(github.com/riverqueue) | ||
| gomoddirectives: | ||
| replace-local: true | ||
|
|
||
| gomoddirectives: | ||
| replace-local: true | ||
| gosec: | ||
| excludes: | ||
| - G404 # use of non-crypto random; overly broad for our use case | ||
|
|
||
| gosec: | ||
| excludes: | ||
| - G404 # use of non-crypto random; overly broad for our use case | ||
| revive: | ||
| rules: | ||
| - name: unused-parameter | ||
| disabled: true | ||
|
|
||
| revive: | ||
| rules: | ||
| - name: unused-parameter | ||
| disabled: true | ||
| tagliatelle: | ||
| case: | ||
| rules: | ||
| json: snake | ||
|
|
||
| tagliatelle: | ||
| case: | ||
| rules: | ||
| json: snake | ||
| testifylint: | ||
| enable-all: true | ||
| disable: | ||
| - go-require | ||
|
|
||
| varnamelen: | ||
| ignore-names: | ||
| - db | ||
| - eg | ||
| - f | ||
| - i | ||
| - id | ||
| - j | ||
| - mu | ||
| - r | ||
| - sb # common convention for string builder | ||
| - t | ||
| - tt # common convention for table tests | ||
| - tx | ||
| - w | ||
| - wg | ||
|
|
||
| exclusions: | ||
| generated: lax | ||
| presets: | ||
| - comments | ||
| - common-false-positives | ||
| - legacy | ||
| - std-error-handling | ||
| rules: | ||
| - path: (.+)\.go$ | ||
| text: Error return value of .(\w+\.Rollback(.*)). is not checked | ||
|
|
||
| testifylint: | ||
| enable-all: true | ||
| disable: | ||
| - go-require | ||
| formatters: | ||
| enable: | ||
| - gci | ||
| - gofmt | ||
| - gofumpt | ||
| - goimports | ||
|
|
||
| varnamelen: | ||
| ignore-names: | ||
| - db | ||
| - eg | ||
| - f | ||
| - i | ||
| - id | ||
| - j | ||
| - mu | ||
| - sb # common convention for string builder | ||
| - t | ||
| - tt # common convention for table tests | ||
| - tx | ||
| - wg | ||
| settings: | ||
| gci: | ||
| sections: | ||
| - Standard | ||
| - Default | ||
| - Prefix(github.com/riverqueue) | ||
| - Prefix(riverqueue.com/riverpro) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -99,10 +99,13 @@ func JobList(ctx context.Context, exec riverdriver.Executor, params *JobListPara | |
|
|
||
| for i, orderBy := range params.OrderBy { | ||
| orderByBuilder.WriteString(orderBy.Expr) | ||
| if orderBy.Order == SortOrderAsc { | ||
| switch orderBy.Order { | ||
| case SortOrderAsc: | ||
| orderByBuilder.WriteString(" ASC") | ||
| } else if orderBy.Order == SortOrderDesc { | ||
| case SortOrderDesc: | ||
| orderByBuilder.WriteString(" DESC") | ||
| case SortOrderUnspecified: | ||
|
Contributor
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. Maybe this should actually be an error 🤔
Contributor
Author
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. 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 ... |
||
| return nil, errors.New("should not have gotten SortOrderUnspecified by this point before executing list (bug?)") | ||
| } | ||
| if i < len(params.OrderBy)-1 { | ||
| orderByBuilder.WriteString(", ") | ||
|
|
||
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.