Skip to content

Commit 5d82c7c

Browse files
Update golangci-lint rules
1 parent 1a62569 commit 5d82c7c

3 files changed

Lines changed: 13 additions & 13 deletions

File tree

.golangci.yml

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,29 +18,25 @@ formatters:
1818
linters:
1919
default: all
2020
disable:
21+
- cyclop # I prefer cognitive complexity
2122
- decorder # Don't care about this
2223
- dupl # Basically every table driven test ever triggers this
2324
- dupword # Messes with test cases more often than not
24-
- err113 # Out of date
25+
- err113 # Opaque errors are fine
2526
- exhaustruct # No
2627
- forbidigo # Nothing to forbid
2728
- funlen # Bad metric for complexity
28-
- ginkgolinter # I don't use whatever this is
29-
- gochecknoglobals # Globals are fine sometimes, use common sense
30-
- gocognit # Cmplexity with another name, don't need both
31-
- gocyclo # cyclop does this instead
29+
- gocyclo # I prefer cognitive complexity
3230
- godox # "todo" and "fixme" comments are allowed
3331
- goheader # No need
3432
- gosmopolitan # No need
3533
- grouper # Imports take care of themselves, rest is common sense
36-
- ireturn # This is just not necessary or practical in a real codebase
34+
- ireturn # Returning an interface is sometimes a good abstraction
3735
- lll # Auto formatters do this and what they can't do I don't care about
38-
- maintidx # This is just the inverse of complexity... which is cyclop
39-
- nestif # cyclop does this
40-
- nlreturn # Similar to wsl, I think best left to judgement
36+
- nlreturn # Similar to wsl
4137
- noinlineerr # Inline errors are fine
42-
- nonamedreturns # Named returns are often helpful, it's naked returns that are the issue
43-
- paralleltest # I've never had Go tests take longer than a few seconds, it's fine
38+
- nonamedreturns # Used sparingly in short functions these are fine
39+
- paralleltest # This makes go test -v ./... much more difficult to read
4440
- thelper # Lots of false positives in here due to the way I do table tests
4541
- unparam # gopls is better and more subtle
4642
- varnamelen # Lots of false positives of things that are fine
@@ -57,6 +53,8 @@ linters:
5753
linters:
5854
- prealloc # These kinds of optimisations will make no difference to test code
5955
- gosec # Tests don't need security stuff
56+
- gochecknoglobals # e.g. global test flags
57+
- maintidx # Flags table driven tests
6058

6159
settings:
6260
cyclop:

internal/arg/arg.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ func (a Arg[T]) Type() string {
225225

226226
// Set sets an [Arg] value by parsing it's string value.
227227
//
228-
//nolint:cyclop // No other way of doing this realistically
228+
//nolint:gocognit,maintidx // No other way of doing this realistically
229229
func (a Arg[T]) Set(str string) error {
230230
if a.value == nil {
231231
return fmt.Errorf("cannot set value %s, arg.value was nil", str)

internal/flag/flag.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,9 @@ func (f Flag[T]) Type() string { //nolint:cyclop // No other way of doing this r
257257
}
258258

259259
// Set sets a [Flag] value based on string input, i.e. parsing from the command line.
260-
func (f Flag[T]) Set(str string) error { //nolint:gocognit,cyclop // No other way of doing this realistically
260+
//
261+
//nolint:gocognit,maintidx // No other way of doing this realistically
262+
func (f Flag[T]) Set(str string) error {
261263
if f.value == nil {
262264
return fmt.Errorf("cannot set value %s, flag.value was nil", str)
263265
}

0 commit comments

Comments
 (0)