-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
🌟 Let's talk about linters section of the configuration #5299
Comments
I think removing presets sounds like a good idea exactly for your reasoning. I think most linters don't actually find bugs but more style that might be a bug. Is the key/name export default [
somePreset,
{ /* other rules */ }
] I'm not sure I like that for Sadly, I don't know what would be much better and I'm open to changing my mind, but maybe linters:
config: standard
enable:
- linter-not-in-standard
disable:
- linter-in-standard-i-dont-want golangci-lint run --config no-linters --enable gofmt I see your very clear off topic note there, but I can't completely ignore the idea of being able to have a set of linters/settings and then being able to extend it in the back of my head as well which also influences my feelings on this topic. Just to clarify, |
About
Note: This is not
This is not a rename.
It's a kind of "hidden" preset. The replacement of
|
Oops, yes I mean
If golangci-lint/pkg/commands/flagsets.go Lines 27 to 28 in e85310c
golangci-lint/.golangci.reference.yml Lines 269 to 271 in e85310c
|
I recommend reading this comment: #1909 (comment) TLDR: it filters The documentation is right and wrong at the same time 😸 Your comments prove that nearly nobody understands how |
Just a note: |
Yep, all clear, just trying to think about the future without thinking to much about the future here 😸 Given the linked comment, I totally see what |
Important
This is a proposal: I don't know if it is possible and what the impact could be inside the code.
The proposal may evolve.
This is an attempt to summarize and provide a solution for the management of the linters inside the configuration.
The current configuration looks like this:
⛑️ The Problems
Presets
Existing presets
asasalint
asciicheck
bidichk
bodyclose
canonicalheader
containedctx
contextcheck
copyloopvar
cyclop
decorder
depguard
dogsled
dupl
dupword
durationcheck
err113
errcheck
errchkjson
errname
errorlint
exhaustive
exhaustruct
exptostd
fatcontext
forbidigo
forcetypeassert
funlen
gci
ginkgolinter
gocheckcompilerdirectives
gochecknoglobals
gochecknoinits
gochecksumtype
gocognit
goconst
gocritic
gocyclo
godot
godox
gofmt
gofumpt
goheader
goimports
gomoddirectives
gomodguard
goprintffuncname
gosec
gosimple
gosmopolitan
govet
grouper
iface
importas
inamedparam
ineffassign
interfacebloat
intrange
ireturn
lll
loggercheck
maintidx
makezero
mirror
misspell
mnd
musttag
nakedret
nestif
nilerr
nilnesserr
nilnil
nlreturn
noctx
nolintlint
nonamedreturns
nosprintfhostport
paralleltest
perfsprint
prealloc
predeclared
promlinter
protogetter
reassign
recvcheck
revive
rowserrcheck
sloglint
spancheck
sqlclosecheck
staticcheck
stylecheck
tagalign
tagliatelle
tenv
testableexamples
testifylint
testpackage
thelper
tparallel
unconvert
unparam
unused
usestdlibvars
usetesting
varnamelen
wastedassign
whitespace
wrapcheck
wsl
zerologlint
The current
presets
option is not related to "presets" but to "categories"/topics.The scope of a preset is too large because they are "categories"/topics and not a consistent or recommended subset of linters as expected by the name "presets".
I think this is difficult to use because there are a lot of linters, linters are in several "presets", and a "preset" can contain potential "incompatible" linters.
ex:
complexity
:cyclop
andgocyclo
are redundantformat
:gci
,gofmt
,gofumpt
,goimports
are mainly redudant (cf proposal about formatters) and "incompatible".bugs
:exhaustive
,gochecksumtype
can be related to bugs but they are very specific.rowserrcheck
is insidesql
andbugs
Note: I use quotes around the word "categories" because it can be ambiguous due to the field
Category
inside theanalysis.Diagnostic
structure.Default Linters
The current default set of linters is small and contains only "slow linters" and cannot be changed without a breaking change.
enable-all and disable-all
The options
enable-all
anddisable-all
are extremely useful.enable-all
#1888But they have some "unexpected" behaviors:
disable
cannot be used withdisable-all
enable
cannot be used withenable-all
In some way, these options are fighting against the default set of linters.
Fast
The
fast
option has an unexpected behavior: this is not a filter.Misc.
Also
linters-settings
option name contains a grammatical error: it should belinter-settings
(note thes
at the end of the wordlinter
).💭 The Proposal
presets
option. For now, I don't know if it is useful to provide a replacement due to the nature of this option but maybetopics
.enable-all
anddisable-all
options.fast
option.default
:standard
(ordefault-v1
, orlegacy
): It enables the current default set of linters. This value will be the default.default-v1
, orlegacy
, we can create a new set of "default" linters calledstandard
ordefault-v2
.all
: this is the equivalent ofenable-all
. It enables all linters.none
: this is the equivalent ofdisable-all
. It disables all linters.fast
: Similar to the currentfast
. It enables all "fast" linters but this is not a filter on other enabled linters.recommended
: an "evolving" list of linters that we recommend for all projects. (This one can be ambiguous, so we can ignore it for now)--fast-only
: a filter on the enabled linters. (similar to--enable-only
)linters-settings
and replace it with a subsectionsettings
insidelinters
Caution
Shareable configuration is another topic, and will not be handled in v2, so everything related to that is off-topic for now.
But be sure that the topic will be handled in the future.
The text was updated successfully, but these errors were encountered: