You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Specify them something like this (copy/paste from another repo, not customized for our linters):
linters:
enable:
- dogsled
- dupl
- gocognit
- goconst
- gocritic
- gocyclo
- gofmt
- golint
- gosec
- maligned
- nakedret
- prealloc
- scopelint
- unconvert
- unparam
- whitespacelinters-settings:
funlen:
lines: 60statements: 40gocognit:
# minimal code complexity to report, 30 by default (but we recommend 10-20)min-complexity: 10gocyclo:
# minimal code complexity to report, 30 by default (but we recommend 10-20)min-complexity: 15golint:
# minimal confidence for issues, default is 0.8min-confidence: 0.3maligned:
# print struct with more effective memory layout or not, false by defaultsuggest-new: truenakedret:
# make an issue if func has more lines of code than this setting and it has naked returns; default is 30max-func-lines: 2unparam:
# Inspect exported functions, default is false. Set to true if no external program/library imports your code.# XXX: if you enable this setting, unparam will report a lot of false-positives in text editors:# if it's called for subdir of a project it can't find external interfaces. All text editor integrations# with golangci-lint call it on a directory with the changed file.check-exported: trueunused:
# treat code as a program (not a library) and report unused exported identifiers; default is false.# XXX: if you enable this setting, unused will report a lot of false-positives in text editors:# if it's called for subdir of a project it can't find funcs usages. All text editor integrations# with golangci-lint call it on a directory with the changed file.check-exported: falsewhitespace:
# Enforces newlines (or comments) after every multi-line if statementmulti-if: true# Enforces newlines (or comments) after every multi-line function signaturemulti-func: trueissues:
# Not using default exclusions because we want to require comments on public# functions and types.exclude-use-default: false# options for analysis runningrun:
# include test files or not, default is truetests: false# by default isn't set. If set we pass it to "go list -mod={option}". From "go help modules":# If invoked with -mod=readonly, the go command is disallowed from the implicit# automatic updating of go.mod described above. Instead, it fails when any changes# to go.mod are needed. This setting is most useful to check that go.mod does# not need updates, such as in a continuous integration and testing system.# If invoked with -mod=vendor, the go command assumes that the vendor# directory holds the correct copies of dependencies and ignores# the dependency descriptions in go.mod.modules-download-mode: vendorservice:
# use the fixed version to not introduce new linters unexpectedlygolangci-lint-version: 1.20.x
Why
By having an external config file (that is picked up automatically), this can be used in the Makefile, in manual golangci-lint runs and (I believe) via Visual Studio Code when golangci-lint is set as the default linter. It would be good to be able to set the linting options in one place and have all applicable use cases covered.
Summary:
- Move linter choices from Makefile to separate include file
- Add scopelint linter to help catch variable use
outside of intended scope
References:
- #42
- #44
- atc0005/todo#4
- dasrick/go-teams-notify#14
What
Instead of specifying the options like this:
Specify them something like this (copy/paste from another repo, not customized for our linters):
Why
By having an external config file (that is picked up automatically), this can be used in the Makefile, in manual
golangci-lint
runs and (I believe) via Visual Studio Code whengolangci-lint
is set as the default linter. It would be good to be able to set the linting options in one place and have all applicable use cases covered.References
The text was updated successfully, but these errors were encountered: