Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ jobs:
name: CI
permissions:
contents: read
uses: FollowTheProcess/ci/.github/workflows/Go.yml@v1
uses: FollowTheProcess/ci/.github/workflows/Go.yml@v2
255 changes: 137 additions & 118 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
version: "2"

formatters:
enable:
- gofumpt
- goimports

settings:
gofumpt:
extra-rules: true

linters:
enable-all: true
default: all
disable:
- decorder # Don't care about this
- dupl # Basically every table driven test ever triggers this
Expand All @@ -8,9 +19,9 @@ linters:
- exhaustruct # No
- forbidigo # Nothing to forbid
- funlen # Bad metric for complexity
- gci # gofmt/goimports is fine
- ginkgolinter # I don't use whatever this is
- gochecknoglobals # Globals are fine sometimes, use common sense
- gocognit # Cmplexity with another name, don't need both
- gocyclo # cyclop does this instead
- godox # "todo" and "fixme" comments are allowed
- goheader # No need
Expand All @@ -22,125 +33,133 @@ linters:
- nestif # cyclop does this
- nlreturn # Similar to wsl, I think best left to judgement
- nonamedreturns # Named returns are often helpful, it's naked returns that are the issue
- paralleltest # No need
- tenv # Replaced by usetesting
- thelper # Lots of false positives due to the way I do table tests in here
- paralleltest # I've never had Go tests take longer than a few seconds, it's fine
- thelper # Lots of false positives in here due to the way I do table tests
- unparam # gopls is better and more subtle
- varnamelen # Lots of false positives of things that are fine
- wrapcheck # Not every error must be wrapped
- wsl # Very aggressive, some of this I like but tend to do anyway

issues:
exclude-rules:
- path: _test\.go
linters:
- prealloc # These kinds of optimisations will make no difference to test code

linters-settings:
cyclop:
max-complexity: 20

depguard:
exclusions:
presets:
# See https://golangci-lint.run/usage/false-positives/#exclusion-presets
- comments # Revive in particular has lots of false positives
- std-error-handling
- common-false-positives
rules:
main:
deny:
- pkg: io/ioutil
desc: io/ioutil is deprecated, use io instead

- pkg: "math/rand$"
desc: use math/rand/v2 instead

errcheck:
check-type-assertions: true
check-blank: true

exhaustive:
check:
- switch
- map
default-signifies-exhaustive: true

staticcheck:
checks:
- all

gosimple:
checks:
- all

govet:
enable-all: true

gofumpt:
extra-rules: true

nakedret:
max-func-lines: 0 # Disallow any naked returns

nolintlint:
allow-unused: false
require-explanation: true
require-specific: true

usetesting:
context-background: true
context-todo: true
os-chdir: true
os-mkdir-temp: true
os-setenv: true
os-create-temp: true
os-temp-dir: true

revive:
max-open-files: 256
ignore-generated-header: true
enable-all-rules: true
rules:
- name: add-constant
disabled: true # goconst does this

- name: argument-limit
arguments:
- 5

- name: cognitive-complexity
disabled: true # gocognit does this

- name: comment-spacings
arguments:
- "nolint:"

- name: cyclomatic
disabled: true # cyclop does this

- name: exported
arguments:
- checkPrivateReceivers
- checkPublicInterface

- name: function-length
disabled: true # Bad proxy for complexity

- name: function-result-limit
arguments:
- 3

- name: import-shadowing
disabled: true # predeclared does this

- name: line-length-limit
disabled: true # gofmt/golines handles this well enough

- name: redefines-builtin-id
disabled: true # predeclared does this

- name: unhandled-error
arguments:
- fmt\.(Fp|P)rint(ln|f)?
- strings.Builder.Write(String|Byte)?
- bytes.Buffer.Write(String|Byte)?

- name: unused-parameter
disabled: true # Leaves a mess of _ in test cases etc.
- path: _test\.go
linters:
- prealloc # These kinds of optimisations will make no difference to test code
- gosec # Tests don't need security stuff

settings:
cyclop:
max-complexity: 20

depguard:
rules:
main:
deny:
- pkg: io/ioutil
desc: io/ioutil is deprecated, use io instead

- pkg: "math/rand$"
desc: use math/rand/v2 instead

errcheck:
check-type-assertions: true
check-blank: true

exhaustive:
check:
- switch
- map
default-signifies-exhaustive: true

staticcheck:
checks:
- all

gosec:
excludes:
- G104 # Errors not checked, handled by errcheck

govet:
enable-all: true

nakedret:
max-func-lines: 0 # Disallow any naked returns

nolintlint:
allow-unused: false
require-explanation: true
require-specific: true

usetesting:
context-background: true
context-todo: true
os-chdir: true
os-mkdir-temp: true
os-setenv: true
os-create-temp: true
os-temp-dir: true

revive:
max-open-files: 256
enable-all-rules: true
rules:
- name: add-constant
disabled: true # goconst does this

- name: argument-limit
arguments:
- 5

- name: cognitive-complexity
disabled: true # gocognit does this

- name: comment-spacings
arguments:
- "nolint:"

- name: cyclomatic
disabled: true # cyclop does this

- name: exported
arguments:
- checkPrivateReceivers
- checkPublicInterface

- name: function-length
disabled: true # Bad proxy for complexity

- name: function-result-limit
arguments:
- 3

- name: import-shadowing
disabled: true # predeclared does this

- name: line-length-limit
disabled: true # gofmt/golines handles this well enough

- name: max-public-structs
disabled: true # This is a dumb rule

- name: redefines-builtin-id
disabled: true # predeclared does this

- name: unhandled-error
arguments:
- fmt\.(Fp|P)rint(ln|f)?
- strings.Builder.Write(String|Byte)?
- bytes.Buffer.Write(String|Byte)?

- name: flag-parameter
disabled: true # As far as I can work out this just doesn't like bools

- name: unused-parameter
disabled: true # The gopls unused analyzer covers this better

- name: unused-receiver
disabled: true # As above
- name: unused-receiver
disabled: true # As above
4 changes: 0 additions & 4 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,8 @@ tasks:
desc: Run go fmt on all source files
sources:
- "**/*.go"
preconditions:
- sh: command -v golines
msg: golines not installed, see https://github.com/segmentio/golines
cmds:
- go fmt ./...
- golines . --ignore-generated --write-output --max-len 120

test:
desc: Run the test suite
Expand Down
2 changes: 1 addition & 1 deletion examples/subcommands/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ func BuildCLI() (*cli.Command, error) {

type sayOptions struct {
thing string
items []string
count int
shout bool
items []string
}

func buildSayCommand() (*cli.Command, error) {
Expand Down
Loading