Skip to content
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

way to identify newly available linters #1686

Closed
wyardley opened this issue Feb 3, 2021 · 12 comments · Fixed by #2039
Closed

way to identify newly available linters #1686

wyardley opened this issue Feb 3, 2021 · 12 comments · Fixed by #2039
Labels
enhancement New feature or improvement

Comments

@wyardley
Copy link

wyardley commented Feb 3, 2021

Is your feature request related to a problem? Please describe.
Just curious - given the deprecation of enable-all (e.g., #542 (comment)), is there any way to find out what linters are newly available, shy of comparing the list of enabled ones to the full list on the site?

It would be extremely useful if there were an option to print available (but not enabled) linters. Also, it's great that golangci-lint supports a lot of different types of linters, but sometimes it could be more clear which ones are recommended for typical use cases, so some kind of opinionated preset would also be nice.

IMO, the recommendation it seems is being made (to explicitly list all linters by name one by one in each project's config) is a bit of a hassle / maintenance headache.

Describe the solution you'd like
A couple options - one would be a command line flag to print all available, but not enabled linters based on the current version of the tool and the current project's config.

Optionally, some other way to restore the previous behavior of allowing one to move to a more "disable explicit" mode and / or some kind of "recommended" config that would continue to add the most useful of new linters automagically.

Describe alternatives you've considered
Some kind of way to define an org-wide preset (similar to tools like, say, eslint for node) might be interesting.

Additional context
Add any other context or screenshots about the feature request here.

@wyardley wyardley added the enhancement New feature or improvement label Feb 3, 2021
@boring-cyborg
Copy link

boring-cyborg bot commented Feb 3, 2021

Hey, thank you for opening your first Issue ! 🙂 If you would like to contribute we have a guide for contributors.

@ldez
Copy link
Member

ldez commented Feb 3, 2021

@wyardley
Copy link
Author

wyardley commented Feb 3, 2021

@ldez Hi -- yes, I know that
in practical terms though, it's not very efficient / simple to go to that page, and try to manually compare it against a yaml file with a list of 30-40+ linters. People also tend to consider these types of configs to be "set it and forget it", so it also makes it very easy for (useful) new linters to come out, but for people to not know about them / enable them.

Then, magnify this times the number of projects one has these settings / configs for.

IMO, the older (but deprecated) method of being able to pin to a specific version's linters (and disabling unwanted ones explicitly) was easier to work with.

@ldez
Copy link
Member

ldez commented Feb 3, 2021

Personally, I like enable-all, I'm not convinced by the deprecation proposal.

I think that an enhancement can be made in the linters manager by adding a Since/IntroducedIn field in the Config structure.

lcs := []*linter.Config{
linter.NewConfig(golinters.NewGovet(govetCfg)).
WithLoadForGoAnalysis().
WithPresets(linter.PresetBugs).
WithAlternativeNames("vet", "vetshadow").
WithURL("https://golang.org/cmd/vet/"),
linter.NewConfig(golinters.NewBodyclose()).
WithLoadForGoAnalysis().
WithPresets(linter.PresetPerformance, linter.PresetBugs).
WithURL("https://github.com/timakin/bodyclose"),
linter.NewConfig(golinters.NewNoctx()).
WithLoadForGoAnalysis().
WithPresets(linter.PresetPerformance, linter.PresetBugs).
WithURL("https://github.com/sonatard/noctx"),
linter.NewConfig(golinters.NewErrcheck()).
WithLoadForGoAnalysis().
WithPresets(linter.PresetBugs).
WithURL("https://github.com/kisielk/errcheck"),
linter.NewConfig(golinters.NewGolint()).
WithLoadForGoAnalysis().
WithPresets(linter.PresetStyle).
WithURL("https://github.com/golang/lint"),
linter.NewConfig(golinters.NewRowsErrCheck()).
WithLoadForGoAnalysis().
WithPresets(linter.PresetPerformance, linter.PresetBugs).
WithURL("https://github.com/jingyugao/rowserrcheck"),
linter.NewConfig(golinters.NewStaticcheck()).
WithLoadForGoAnalysis().
WithPresets(linter.PresetBugs).
WithAlternativeNames(megacheckName).
WithURL("https://staticcheck.io/"),
linter.NewConfig(golinters.NewUnused()).
WithLoadForGoAnalysis().
WithPresets(linter.PresetUnused).
WithAlternativeNames(megacheckName).
ConsiderSlow().
WithChangeTypes().
WithURL("https://github.com/dominikh/go-tools/tree/master/unused"),
linter.NewConfig(golinters.NewGosimple()).
WithLoadForGoAnalysis().
WithPresets(linter.PresetStyle).
WithAlternativeNames(megacheckName).
WithURL("https://github.com/dominikh/go-tools/tree/master/simple"),
linter.NewConfig(golinters.NewStylecheck()).
WithLoadForGoAnalysis().
WithPresets(linter.PresetStyle).
WithURL("https://github.com/dominikh/go-tools/tree/master/stylecheck"),
linter.NewConfig(golinters.NewGosec()).
WithLoadForGoAnalysis().
WithPresets(linter.PresetBugs).
WithURL("https://github.com/securego/gosec").
WithAlternativeNames("gas"),
linter.NewConfig(golinters.NewStructcheck()).
WithLoadForGoAnalysis().
WithPresets(linter.PresetUnused).
WithURL("https://github.com/opennota/check"),
linter.NewConfig(golinters.NewVarcheck()).
WithLoadForGoAnalysis().
WithPresets(linter.PresetUnused).
WithURL("https://github.com/opennota/check"),
linter.NewConfig(golinters.NewInterfacer()).
WithLoadForGoAnalysis().
WithPresets(linter.PresetStyle).
WithURL("https://github.com/mvdan/interfacer"),
linter.NewConfig(golinters.NewUnconvert()).
WithLoadForGoAnalysis().
WithPresets(linter.PresetStyle).
WithURL("https://github.com/mdempsky/unconvert"),
linter.NewConfig(golinters.NewIneffassign()).
WithPresets(linter.PresetUnused).
WithURL("https://github.com/gordonklaus/ineffassign"),
linter.NewConfig(golinters.NewDupl()).
WithPresets(linter.PresetStyle).
WithURL("https://github.com/mibk/dupl"),
linter.NewConfig(golinters.NewGoconst()).
WithPresets(linter.PresetStyle).
WithURL("https://github.com/jgautheron/goconst"),
linter.NewConfig(golinters.NewDeadcode()).
WithLoadForGoAnalysis().
WithPresets(linter.PresetUnused).
WithURL("https://github.com/remyoudompheng/go-misc/tree/master/deadcode"),
linter.NewConfig(golinters.NewGocyclo()).
WithPresets(linter.PresetComplexity).
WithURL("https://github.com/alecthomas/gocyclo"),
linter.NewConfig(golinters.NewGocognit()).
WithPresets(linter.PresetComplexity).
WithURL("https://github.com/uudashr/gocognit"),
linter.NewConfig(golinters.NewTypecheck()).
WithLoadForGoAnalysis().
WithPresets(linter.PresetBugs).
WithURL(""),
linter.NewConfig(golinters.NewAsciicheck()).
WithPresets(linter.PresetBugs, linter.PresetStyle).
WithURL("https://github.com/tdakkota/asciicheck"),
linter.NewConfig(golinters.NewGofmt()).
WithPresets(linter.PresetFormatting).
WithAutoFix().
WithURL("https://golang.org/cmd/gofmt/"),
linter.NewConfig(golinters.NewGofumpt()).
WithPresets(linter.PresetFormatting).
WithAutoFix().
WithURL("https://github.com/mvdan/gofumpt"),
linter.NewConfig(golinters.NewGoimports()).
WithPresets(linter.PresetFormatting).
WithAutoFix().
WithURL("https://godoc.org/golang.org/x/tools/cmd/goimports"),
linter.NewConfig(golinters.NewGoHeader()).
WithPresets(linter.PresetStyle).
WithLoadForGoAnalysis().
WithURL("https://github.com/denis-tingajkin/go-header"),
linter.NewConfig(golinters.NewGci()).
WithLoadForGoAnalysis().
WithAutoFix().
WithURL("https://github.com/daixiang0/gci"),
linter.NewConfig(golinters.NewMaligned()).
WithLoadForGoAnalysis().
WithPresets(linter.PresetPerformance).
WithURL("https://github.com/mdempsky/maligned"),
linter.NewConfig(golinters.NewDepguard()).
WithLoadForGoAnalysis().
WithPresets(linter.PresetStyle).
WithURL("https://github.com/OpenPeeDeeP/depguard"),
linter.NewConfig(golinters.NewMisspell()).
WithPresets(linter.PresetStyle).
WithAutoFix().
WithURL("https://github.com/client9/misspell"),
linter.NewConfig(golinters.NewLLL()).
WithPresets(linter.PresetStyle).
WithURL("https://github.com/walle/lll"),
linter.NewConfig(golinters.NewUnparam()).
WithPresets(linter.PresetUnused).
WithLoadForGoAnalysis().
WithURL("https://github.com/mvdan/unparam"),
linter.NewConfig(golinters.NewDogsled()).
WithPresets(linter.PresetStyle).
WithURL("https://github.com/alexkohler/dogsled"),
linter.NewConfig(golinters.NewNakedret()).
WithPresets(linter.PresetComplexity).
WithURL("https://github.com/alexkohler/nakedret"),
linter.NewConfig(golinters.NewPrealloc()).
WithPresets(linter.PresetPerformance).
WithURL("https://github.com/alexkohler/prealloc"),
linter.NewConfig(golinters.NewScopelint()).
WithPresets(linter.PresetBugs).
WithURL("https://github.com/kyoh86/scopelint"),
linter.NewConfig(golinters.NewGocritic()).
WithPresets(linter.PresetStyle).
WithLoadForGoAnalysis().
WithURL("https://github.com/go-critic/go-critic"),
linter.NewConfig(golinters.NewGochecknoinits()).
WithPresets(linter.PresetStyle).
WithURL("https://github.com/leighmcculloch/gochecknoinits"),
linter.NewConfig(golinters.NewGochecknoglobals()).
WithPresets(linter.PresetStyle).
WithURL("https://github.com/leighmcculloch/gochecknoglobals"),
linter.NewConfig(golinters.NewGodox()).
WithPresets(linter.PresetStyle).
WithURL("https://github.com/matoous/godox"),
linter.NewConfig(golinters.NewFunlen()).
WithPresets(linter.PresetStyle).
WithURL("https://github.com/ultraware/funlen"),
linter.NewConfig(golinters.NewWhitespace()).
WithPresets(linter.PresetStyle).
WithAutoFix().
WithURL("https://github.com/ultraware/whitespace"),
linter.NewConfig(golinters.NewWSL()).
WithPresets(linter.PresetStyle).
WithURL("https://github.com/bombsimon/wsl"),
linter.NewConfig(golinters.NewGoPrintfFuncName()).
WithPresets(linter.PresetStyle).
WithURL("https://github.com/jirfag/go-printf-func-name"),
linter.NewConfig(golinters.NewGoMND(m.cfg)).
WithPresets(linter.PresetStyle).
WithURL("https://github.com/tommy-muehle/go-mnd"),
linter.NewConfig(golinters.NewGoerr113()).
WithPresets(linter.PresetStyle).
WithLoadForGoAnalysis().
WithURL("https://github.com/Djarvur/go-err113"),
linter.NewConfig(golinters.NewGomodguard()).
WithPresets(linter.PresetStyle).
WithLoadForGoAnalysis().
WithURL("https://github.com/ryancurrah/gomodguard"),
linter.NewConfig(golinters.NewGodot()).
WithPresets(linter.PresetStyle).
WithAutoFix().
WithURL("https://github.com/tetafro/godot"),
linter.NewConfig(golinters.NewTestpackage(testpackageCfg)).
WithPresets(linter.PresetStyle).
WithLoadForGoAnalysis().
WithURL("https://github.com/maratori/testpackage"),
linter.NewConfig(golinters.NewNestif()).
WithPresets(linter.PresetComplexity).
WithURL("https://github.com/nakabonne/nestif"),
linter.NewConfig(golinters.NewExportLoopRef()).
WithPresets(linter.PresetBugs).
WithURL("https://github.com/kyoh86/exportloopref"),
linter.NewConfig(golinters.NewExhaustive(exhaustiveCfg)).
WithPresets(linter.PresetBugs).
WithLoadForGoAnalysis().
WithURL("https://github.com/nishanths/exhaustive"),
linter.NewConfig(golinters.NewSQLCloseCheck()).
WithPresets(linter.PresetBugs).
WithLoadForGoAnalysis().
WithURL("https://github.com/ryanrolds/sqlclosecheck"),
linter.NewConfig(golinters.NewNLReturn()).
WithPresets(linter.PresetStyle).
WithLoadForGoAnalysis().
WithURL("https://github.com/ssgreg/nlreturn"),
linter.NewConfig(golinters.NewWrapcheck()).
WithPresets(linter.PresetStyle).
WithLoadForGoAnalysis().
WithURL("https://github.com/tomarrell/wrapcheck"),
linter.NewConfig(golinters.NewThelper(thelperCfg)).
WithPresets(linter.PresetStyle).
WithLoadForGoAnalysis().
WithURL("https://github.com/kulti/thelper"),
linter.NewConfig(golinters.NewTparallel()).
WithPresets(linter.PresetStyle).
WithLoadForGoAnalysis().
WithURL("https://github.com/moricho/tparallel"),
linter.NewConfig(golinters.NewExhaustiveStruct()).
WithPresets(linter.PresetStyle).
WithURL("https://github.com/mbilski/exhaustivestruct"),
linter.NewConfig(golinters.NewErrorLint(errorlintCfg)).
WithPresets(linter.PresetBugs).
WithLoadForGoAnalysis().
WithURL("https://github.com/polyfloyd/go-errorlint"),
linter.NewConfig(golinters.NewParallelTest()).
WithPresets(linter.PresetStyle).
WithLoadForGoAnalysis().
WithURL("https://github.com/kunwardeep/paralleltest"),
linter.NewConfig(golinters.NewMakezero()).
WithPresets(linter.PresetStyle, linter.PresetBugs).
WithURL("https://github.com/ashanbrown/makezero"),
linter.NewConfig(golinters.NewForbidigo()).
WithPresets(linter.PresetStyle).
WithURL("https://github.com/ashanbrown/forbidigo"),
linter.NewConfig(golinters.NewIfshort(ifshortCfg)).
WithPresets(linter.PresetStyle).
WithURL("https://github.com/esimonov/ifshort"),
linter.NewConfig(golinters.NewPredeclared(predeclaredCfg)).
WithPresets(linter.PresetStyle).
WithURL("https://github.com/nishanths/predeclared"),
// nolintlint must be last because it looks at the results of all the previous linters for unused nolint directives
linter.NewConfig(golinters.NewNoLintLint()).
WithPresets(linter.PresetStyle).
WithURL("https://github.com/golangci/golangci-lint/blob/master/pkg/golinters/nolintlint/README.md"),

and add a new flag or subcommand to the golangci-lint linters command to display that information.

@wyardley
Copy link
Author

wyardley commented Feb 3, 2021

Personally, I like enable-all, I'm not convinced by the deprecation proposal.

Me too! I don't have the reference handy, but I believe it's been made pretty official and is documented somewhere on the main site, but let me know if I'm wrong on that!

I think that an enhancement can be made in the linters manager by adding a Since/IntroducedIn field in the Config structure.
and add a new flag or subcommand to the golangci-lint linters command to display that information.

Like this idea!

@Zamiell
Copy link
Contributor

Zamiell commented Feb 4, 2021

For what its worth, I also use enable-all.
This way, when I upgrade my version of golang-ci, I automatically get the benefits of any new linters.
If the new linters are noise, I can then explicitly add them to the disable array my .golangci.yml file.
This workflow is very nice, because I notably don't have to do any research on the main page to find what the linters are, as wyardley rightly points out above.

Is there any links to why enable-all is being deprecated?

@wyardley
Copy link
Author

wyardley commented Feb 4, 2021

Is there any links to why enable-all is being deprecated?

https://golangci-lint.run/usage/configuration/
has a comment:

please, do not use enable-all: it's deprecated and will be removed soon.
inverted configuration with enable-all and disable is not scalable during updates of golangci-lint

which comes from

# please, do not use `enable-all`: it's deprecated and will be removed soon.
# inverted configuration with `enable-all` and `disable` is not scalable during updates of golangci-lint

added in #803

@ashanbrown
Copy link
Contributor

ashanbrown commented Feb 4, 2021

Maybe it would be worth adding an enable-new command that adds any unmentioned linters to the config file. While I liked using enable-all, I can see why it would be annoying for someone just trying to upgrade to a new version of golangci-lint that supports a new go version, for example.

@bombsimon
Copy link
Member

I also use enable-all. If you manually upgrade and know when a new version is installed you could also just check the release page which will list all added linters in each release.

@ldez
Copy link
Member

ldez commented Mar 24, 2021

I added a Since field on all linters (#1854) so now you can see the versions (and also the deprecations) in the documentation:

https://golangci-lint.run/usage/linters/

I have an idea for a command line approach but I need to think more about it.

@Zamiell
Copy link
Contributor

Zamiell commented Mar 24, 2021

Nice work, thanks.

@ldez
Copy link
Member

ldez commented Apr 4, 2021

I would like to (re)open the debate about the deprecation of enable-all so I opened #1888.

So please describe your use-cases in this new issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or improvement
Projects
None yet
5 participants