-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Closed
Labels
duplicateThis issue or pull request already existsThis issue or pull request already existsquestionFurther information is requestedFurther information is requested
Description
Welcome
- Yes, I'm using a binary release within 2 latest major releases. Only such installations are supported.
- Yes, I've searched similar issues on GitHub and didn't find any.
- Yes, I've read the typecheck section of the FAQ (https://golangci-lint.run/usage/faq/#why-do-you-have-typecheck-errors).
- Yes, I've tried with the standalone linter if available (e.g., gocritic, go vet, etc.). (https://golangci-lint.run/usage/linters/)
Description of the problem
I'm unable to disable all linters from the command line when a local config is present, this is awkward as I'd like to reuse linters-settings from the local config for a second run against a different set of directories than the first. For example:
$ yq .linters .golangci.yml
disable-all: true
enable:
- bodyclose
- dogsled
- dupl
- errcheck
- exportloopref
- exhaustive
- funlen
- ginkgolinter
- gochecknoinits
- goconst
- gocritic
- gocyclo
- gofmt
- goheader
- goimports
- gomnd
- goprintffuncname
- gosec
- gosimple
- govet
- ineffassign
- lll
- misspell
- nakedret
- noctx
- nolintlint
- rowserrcheck
- staticcheck
- stylecheck
- typecheck
- unconvert
- unparam
- unused
- whitespace
$ yq .linters-settings.ginkgolinter .golangci.yml
forbid-focus-container: true
$ golangci-lint run --disable-all -E ginkgolinter --verbose
[..]
INFO [lintersdb] Active 33 linters: [bodyclose dogsled dupl errcheck exhaustive exportloopref funlen ginkgolinter gochecknoinits goconst gocritic gocyclo gofmt goheader goimports gomnd goprintffuncname gosec gosimple govet ineffassign lll misspell nakedret noctx nolintlint rowserrcheck staticcheck stylecheck unconvert unparam unused whitespace]
Providing --no-config avoids this but I then loose the ginkgolinter configuration. Without a way of passing these options in through the command line the only real workaround here is to write a second minimal config.
Version of golangci-lint
$ golangci-lint --version
golangci-lint has version 1.54.0 built with go1.21.0 from c1d8c565 on 2023-08-09T11:50:00ZConfiguration
# golangci configuration
linters-settings:
dupl:
threshold: 100
funlen:
lines: 100
statements: 50
gci:
local-prefixes: github.com/kubevirt/kubevirt
goconst:
min-len: 2
min-occurrences: 2
gocritic:
enabled-tags:
- diagnostic
- experimental
- opinionated
- performance
- style
disabled-checks:
- dupImport # https://github.com/go-critic/go-critic/issues/845
- ifElseChain
- octalLiteral
- paramTypeCombine
- whyNoLint
- wrapperFunc
settings:
hugeParam:
sizeThreshold: 1024
rangeValCopy:
sizeThreshold: 1024
gocyclo:
min-complexity: 15
goimports:
local-prefixes: kubevirt.io/kubevirt
gomnd:
settings:
mnd:
# don't include the "operation" and "assign"
checks: argument,case,condition,return
govet:
check-shadowing: true
lll:
line-length: 140
maligned:
suggest-new: true
misspell:
locale: US
nolintlint:
allow-leading-space: true # don't require machine-readable nolint directives (i.e. with no leading space)
allow-unused: false # report any unused nolint directives
require-explanation: false # don't require an explanation for nolint directives
require-specific: false # don't require nolint directives to be specific about which linter is being skipped
stylecheck:
dot-import-whitelist:
- "github.com/onsi/ginkgo/v2"
- "github.com/onsi/gomega"
ginkgolinter:
forbid-focus-container: true
linters:
disable-all: true
enable:
- bodyclose
- dogsled
- dupl
- errcheck
- exportloopref
- exhaustive
- funlen
- ginkgolinter
- gochecknoinits
- goconst
- gocritic
- gocyclo
- gofmt
- goheader
- goimports
- gomnd
- goprintffuncname
- gosec
- gosimple
- govet
- ineffassign
- lll
- misspell
- nakedret
- noctx
- nolintlint
- rowserrcheck
- staticcheck
- stylecheck
- typecheck
- unconvert
- unparam
- unused
- whitespace
# don't enable:
# - asciicheck
# - scopelint
# - gochecknoglobals
# - gocognit
# - godot
# - godox
# - goerr113
# - interfacer
# - maligned
# - nestif
# - prealloc
# - testpackage
# - revive
# - wslGo environment
$ go version
go version go1.19.10 linux/amd64
</details>
### Verbose output of running
<details>
```console
See aboveCode example or link to a public repository
// add your code hereValidation
- Yes, I've included all information above (version, config, etc.).
Metadata
Metadata
Assignees
Labels
duplicateThis issue or pull request already existsThis issue or pull request already existsquestionFurther information is requestedFurther information is requested