dev: use goprintffuncname, gomnd and rowserrcheck (#927)
Order linters in config in alphabetical order. Support gomnd configuration.
This commit is contained in:
parent
88b6c25075
commit
6237e59c97
@ -67,6 +67,12 @@ output:
|
|||||||
|
|
||||||
# all available settings of specific linters
|
# all available settings of specific linters
|
||||||
linters-settings:
|
linters-settings:
|
||||||
|
dogsled:
|
||||||
|
# checks assignments with too many blank identifiers; default is 2
|
||||||
|
max-blank-identifiers: 2
|
||||||
|
dupl:
|
||||||
|
# tokens count to trigger issue, 150 by default
|
||||||
|
threshold: 100
|
||||||
errcheck:
|
errcheck:
|
||||||
# report about not checking of errors in type assetions: `a := b.(MyStruct)`;
|
# report about not checking of errors in type assetions: `a := b.(MyStruct)`;
|
||||||
# default is false: such cases aren't reported by default.
|
# default is false: such cases aren't reported by default.
|
||||||
@ -84,106 +90,17 @@ linters-settings:
|
|||||||
# path to a file containing a list of functions to exclude from checking
|
# path to a file containing a list of functions to exclude from checking
|
||||||
# see https://github.com/kisielk/errcheck#excluding-functions for details
|
# see https://github.com/kisielk/errcheck#excluding-functions for details
|
||||||
exclude: /path/to/file.txt
|
exclude: /path/to/file.txt
|
||||||
|
|
||||||
funlen:
|
funlen:
|
||||||
lines: 60
|
lines: 60
|
||||||
statements: 40
|
statements: 40
|
||||||
|
|
||||||
govet:
|
|
||||||
# report about shadowed variables
|
|
||||||
check-shadowing: true
|
|
||||||
|
|
||||||
# settings per analyzer
|
|
||||||
settings:
|
|
||||||
printf: # analyzer name, run `go tool vet help` to see all analyzers
|
|
||||||
funcs: # run `go tool vet help printf` to see available settings for `printf` analyzer
|
|
||||||
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Infof
|
|
||||||
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Warnf
|
|
||||||
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Errorf
|
|
||||||
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Fatalf
|
|
||||||
|
|
||||||
# enable or disable analyzers by name
|
|
||||||
enable:
|
|
||||||
- atomicalign
|
|
||||||
enable-all: false
|
|
||||||
disable:
|
|
||||||
- shadow
|
|
||||||
disable-all: false
|
|
||||||
golint:
|
|
||||||
# minimal confidence for issues, default is 0.8
|
|
||||||
min-confidence: 0.8
|
|
||||||
gofmt:
|
|
||||||
# simplify code: gofmt with `-s` option, true by default
|
|
||||||
simplify: true
|
|
||||||
goimports:
|
|
||||||
# put imports beginning with prefix after 3rd-party packages;
|
|
||||||
# it's a comma-separated list of prefixes
|
|
||||||
local-prefixes: github.com/org/project
|
|
||||||
gocyclo:
|
|
||||||
# minimal code complexity to report, 30 by default (but we recommend 10-20)
|
|
||||||
min-complexity: 10
|
|
||||||
gocognit:
|
gocognit:
|
||||||
# minimal code complexity to report, 30 by default (but we recommend 10-20)
|
# minimal code complexity to report, 30 by default (but we recommend 10-20)
|
||||||
min-complexity: 10
|
min-complexity: 10
|
||||||
maligned:
|
|
||||||
# print struct with more effective memory layout or not, false by default
|
|
||||||
suggest-new: true
|
|
||||||
dupl:
|
|
||||||
# tokens count to trigger issue, 150 by default
|
|
||||||
threshold: 100
|
|
||||||
goconst:
|
goconst:
|
||||||
# minimal length of string constant, 3 by default
|
# minimal length of string constant, 3 by default
|
||||||
min-len: 3
|
min-len: 3
|
||||||
# minimal occurrences count to trigger, 3 by default
|
# minimal occurrences count to trigger, 3 by default
|
||||||
min-occurrences: 3
|
min-occurrences: 3
|
||||||
depguard:
|
|
||||||
list-type: blacklist
|
|
||||||
include-go-root: false
|
|
||||||
packages:
|
|
||||||
- github.com/sirupsen/logrus
|
|
||||||
packages-with-error-message:
|
|
||||||
# specify an error message to output when a blacklisted package is used
|
|
||||||
- github.com/sirupsen/logrus: "logging is allowed only by logutils.Log"
|
|
||||||
misspell:
|
|
||||||
# Correct spellings using locale preferences for US or UK.
|
|
||||||
# Default is to use a neutral variety of English.
|
|
||||||
# Setting locale to US will correct the British spelling of 'colour' to 'color'.
|
|
||||||
locale: US
|
|
||||||
ignore-words:
|
|
||||||
- someword
|
|
||||||
lll:
|
|
||||||
# max line length, lines longer will be reported. Default is 120.
|
|
||||||
# '\t' is counted as 1 character by default, and can be changed with the tab-width option
|
|
||||||
line-length: 120
|
|
||||||
# tab width in spaces. Default to 1.
|
|
||||||
tab-width: 1
|
|
||||||
rowserrcheck:
|
|
||||||
packages:
|
|
||||||
- github.com/jmoiron/sqlx
|
|
||||||
unused:
|
|
||||||
# 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: false
|
|
||||||
unparam:
|
|
||||||
# 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: false
|
|
||||||
nakedret:
|
|
||||||
# make an issue if func has more lines of code than this setting and it has naked returns; default is 30
|
|
||||||
max-func-lines: 30
|
|
||||||
prealloc:
|
|
||||||
# XXX: we don't recommend using this linter before doing performance profiling.
|
|
||||||
# For most programs usage of prealloc will be a premature optimization.
|
|
||||||
|
|
||||||
# Report preallocation suggestions only on simple loops that have no returns/breaks/continues/gotos in them.
|
|
||||||
# True by default.
|
|
||||||
simple: true
|
|
||||||
range-loops: true # Report preallocation suggestions on range loops, true by default
|
|
||||||
for-loops: false # Report preallocation suggestions on for loops, false by default
|
|
||||||
gocritic:
|
gocritic:
|
||||||
# Which checks should be enabled; can't be combined with 'disabled-checks';
|
# Which checks should be enabled; can't be combined with 'disabled-checks';
|
||||||
# See https://go-critic.github.io/overview#checks-overview
|
# See https://go-critic.github.io/overview#checks-overview
|
||||||
@ -206,6 +123,9 @@ linters-settings:
|
|||||||
paramsOnly: true
|
paramsOnly: true
|
||||||
rangeValCopy:
|
rangeValCopy:
|
||||||
sizeThreshold: 32
|
sizeThreshold: 32
|
||||||
|
gocyclo:
|
||||||
|
# minimal code complexity to report, 30 by default (but we recommend 10-20)
|
||||||
|
min-complexity: 10
|
||||||
godox:
|
godox:
|
||||||
# report any comments starting with keywords, this is useful for TODO or FIXME comments that
|
# report any comments starting with keywords, this is useful for TODO or FIXME comments that
|
||||||
# might be left in the code accidentally and should be resolved before merging
|
# might be left in the code accidentally and should be resolved before merging
|
||||||
@ -213,10 +133,92 @@ linters-settings:
|
|||||||
- NOTE
|
- NOTE
|
||||||
- OPTIMIZE # marks code that should be optimized before merging
|
- OPTIMIZE # marks code that should be optimized before merging
|
||||||
- HACK # marks hack-arounds that should be removed before merging
|
- HACK # marks hack-arounds that should be removed before merging
|
||||||
dogsled:
|
gofmt:
|
||||||
# checks assignments with too many blank identifiers; default is 2
|
# simplify code: gofmt with `-s` option, true by default
|
||||||
max-blank-identifiers: 2
|
simplify: true
|
||||||
|
goimports:
|
||||||
|
# put imports beginning with prefix after 3rd-party packages;
|
||||||
|
# it's a comma-separated list of prefixes
|
||||||
|
local-prefixes: github.com/org/project
|
||||||
|
golint:
|
||||||
|
# minimal confidence for issues, default is 0.8
|
||||||
|
min-confidence: 0.8
|
||||||
|
gomnd:
|
||||||
|
settings:
|
||||||
|
mnd:
|
||||||
|
# the list of enabled checks, see https://github.com/tommy-muehle/go-mnd/#checks for description.
|
||||||
|
checks: argument,case,condition,operation,return,assign
|
||||||
|
govet:
|
||||||
|
# report about shadowed variables
|
||||||
|
check-shadowing: true
|
||||||
|
|
||||||
|
# settings per analyzer
|
||||||
|
settings:
|
||||||
|
printf: # analyzer name, run `go tool vet help` to see all analyzers
|
||||||
|
funcs: # run `go tool vet help printf` to see available settings for `printf` analyzer
|
||||||
|
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Infof
|
||||||
|
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Warnf
|
||||||
|
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Errorf
|
||||||
|
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Fatalf
|
||||||
|
|
||||||
|
# enable or disable analyzers by name
|
||||||
|
enable:
|
||||||
|
- atomicalign
|
||||||
|
enable-all: false
|
||||||
|
disable:
|
||||||
|
- shadow
|
||||||
|
disable-all: false
|
||||||
|
depguard:
|
||||||
|
list-type: blacklist
|
||||||
|
include-go-root: false
|
||||||
|
packages:
|
||||||
|
- github.com/sirupsen/logrus
|
||||||
|
packages-with-error-message:
|
||||||
|
# specify an error message to output when a blacklisted package is used
|
||||||
|
- github.com/sirupsen/logrus: "logging is allowed only by logutils.Log"
|
||||||
|
lll:
|
||||||
|
# max line length, lines longer will be reported. Default is 120.
|
||||||
|
# '\t' is counted as 1 character by default, and can be changed with the tab-width option
|
||||||
|
line-length: 120
|
||||||
|
# tab width in spaces. Default to 1.
|
||||||
|
tab-width: 1
|
||||||
|
maligned:
|
||||||
|
# print struct with more effective memory layout or not, false by default
|
||||||
|
suggest-new: true
|
||||||
|
misspell:
|
||||||
|
# Correct spellings using locale preferences for US or UK.
|
||||||
|
# Default is to use a neutral variety of English.
|
||||||
|
# Setting locale to US will correct the British spelling of 'colour' to 'color'.
|
||||||
|
locale: US
|
||||||
|
ignore-words:
|
||||||
|
- someword
|
||||||
|
nakedret:
|
||||||
|
# make an issue if func has more lines of code than this setting and it has naked returns; default is 30
|
||||||
|
max-func-lines: 30
|
||||||
|
prealloc:
|
||||||
|
# XXX: we don't recommend using this linter before doing performance profiling.
|
||||||
|
# For most programs usage of prealloc will be a premature optimization.
|
||||||
|
|
||||||
|
# Report preallocation suggestions only on simple loops that have no returns/breaks/continues/gotos in them.
|
||||||
|
# True by default.
|
||||||
|
simple: true
|
||||||
|
range-loops: true # Report preallocation suggestions on range loops, true by default
|
||||||
|
for-loops: false # Report preallocation suggestions on for loops, false by default
|
||||||
|
rowserrcheck:
|
||||||
|
packages:
|
||||||
|
- github.com/jmoiron/sqlx
|
||||||
|
unparam:
|
||||||
|
# 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: false
|
||||||
|
unused:
|
||||||
|
# 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: false
|
||||||
whitespace:
|
whitespace:
|
||||||
multi-if: false # Enforces newlines (or comments) after every multi-line if statement
|
multi-if: false # Enforces newlines (or comments) after every multi-line if statement
|
||||||
multi-func: false # Enforces newlines (or comments) after every multi-line function signature
|
multi-func: false # Enforces newlines (or comments) after every multi-line function signature
|
||||||
|
@ -1,24 +1,4 @@
|
|||||||
linters-settings:
|
linters-settings:
|
||||||
govet:
|
|
||||||
check-shadowing: true
|
|
||||||
settings:
|
|
||||||
printf:
|
|
||||||
funcs:
|
|
||||||
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Infof
|
|
||||||
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Warnf
|
|
||||||
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Errorf
|
|
||||||
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Fatalf
|
|
||||||
golint:
|
|
||||||
min-confidence: 0
|
|
||||||
gocyclo:
|
|
||||||
min-complexity: 15
|
|
||||||
maligned:
|
|
||||||
suggest-new: true
|
|
||||||
dupl:
|
|
||||||
threshold: 100
|
|
||||||
goconst:
|
|
||||||
min-len: 2
|
|
||||||
min-occurrences: 2
|
|
||||||
depguard:
|
depguard:
|
||||||
list-type: blacklist
|
list-type: blacklist
|
||||||
packages:
|
packages:
|
||||||
@ -27,12 +7,14 @@ linters-settings:
|
|||||||
- github.com/sirupsen/logrus
|
- github.com/sirupsen/logrus
|
||||||
packages-with-error-message:
|
packages-with-error-message:
|
||||||
- github.com/sirupsen/logrus: "logging is allowed only by logutils.Log"
|
- github.com/sirupsen/logrus: "logging is allowed only by logutils.Log"
|
||||||
misspell:
|
dupl:
|
||||||
locale: US
|
threshold: 100
|
||||||
lll:
|
funlen:
|
||||||
line-length: 140
|
lines: 100
|
||||||
goimports:
|
statements: 50
|
||||||
local-prefixes: github.com/golangci/golangci-lint
|
goconst:
|
||||||
|
min-len: 2
|
||||||
|
min-occurrences: 2
|
||||||
gocritic:
|
gocritic:
|
||||||
enabled-tags:
|
enabled-tags:
|
||||||
- diagnostic
|
- diagnostic
|
||||||
@ -46,16 +28,38 @@ linters-settings:
|
|||||||
- octalLiteral
|
- octalLiteral
|
||||||
- whyNoLint
|
- whyNoLint
|
||||||
- wrapperFunc
|
- wrapperFunc
|
||||||
funlen:
|
gocyclo:
|
||||||
lines: 100
|
min-complexity: 15
|
||||||
statements: 50
|
goimports:
|
||||||
|
local-prefixes: github.com/golangci/golangci-lint
|
||||||
|
golint:
|
||||||
|
min-confidence: 0
|
||||||
|
gomnd:
|
||||||
|
settings:
|
||||||
|
mnd:
|
||||||
|
# don't include the "operation" and "assign"
|
||||||
|
checks: argument,case,condition,return
|
||||||
|
govet:
|
||||||
|
check-shadowing: true
|
||||||
|
settings:
|
||||||
|
printf:
|
||||||
|
funcs:
|
||||||
|
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Infof
|
||||||
|
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Warnf
|
||||||
|
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Errorf
|
||||||
|
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Fatalf
|
||||||
|
lll:
|
||||||
|
line-length: 140
|
||||||
|
maligned:
|
||||||
|
suggest-new: true
|
||||||
|
misspell:
|
||||||
|
locale: US
|
||||||
|
|
||||||
linters:
|
linters:
|
||||||
# please, do not use `enable-all`: it's deprecated and will be removed soon.
|
# 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
|
# inverted configuration with `enable-all` and `disable` is not scalable during updates of golangci-lint
|
||||||
disable-all: true
|
disable-all: true
|
||||||
enable:
|
enable:
|
||||||
# - rowserrcheck
|
|
||||||
- bodyclose
|
- bodyclose
|
||||||
- deadcode
|
- deadcode
|
||||||
- depguard
|
- depguard
|
||||||
@ -70,6 +74,8 @@ linters:
|
|||||||
- gofmt
|
- gofmt
|
||||||
- goimports
|
- goimports
|
||||||
- golint
|
- golint
|
||||||
|
# - gomnd TODO: enable it with release > v1.23.0
|
||||||
|
- goprintffuncname
|
||||||
- gosec
|
- gosec
|
||||||
- gosimple
|
- gosimple
|
||||||
- govet
|
- govet
|
||||||
@ -78,6 +84,7 @@ linters:
|
|||||||
- lll
|
- lll
|
||||||
- misspell
|
- misspell
|
||||||
- nakedret
|
- nakedret
|
||||||
|
- rowserrcheck
|
||||||
- scopelint
|
- scopelint
|
||||||
- staticcheck
|
- staticcheck
|
||||||
- structcheck
|
- structcheck
|
||||||
@ -96,6 +103,13 @@ linters:
|
|||||||
# - maligned
|
# - maligned
|
||||||
# - prealloc
|
# - prealloc
|
||||||
|
|
||||||
|
issues:
|
||||||
|
# Excluding configuration per-path, per-linter, per-text and per-source
|
||||||
|
exclude-rules:
|
||||||
|
- path: _test\.go
|
||||||
|
linters:
|
||||||
|
- gomnd
|
||||||
|
|
||||||
run:
|
run:
|
||||||
skip-dirs:
|
skip-dirs:
|
||||||
- test/testdata_etc
|
- test/testdata_etc
|
||||||
@ -106,6 +120,6 @@ run:
|
|||||||
# golangci.com configuration
|
# golangci.com configuration
|
||||||
# https://github.com/golangci/golangci/wiki/Configuration
|
# https://github.com/golangci/golangci/wiki/Configuration
|
||||||
service:
|
service:
|
||||||
golangci-lint-version: 1.22.x # use the fixed version to not introduce new linters unexpectedly
|
golangci-lint-version: 1.23.x # use the fixed version to not introduce new linters unexpectedly
|
||||||
prepare:
|
prepare:
|
||||||
- echo "here I can run custom commands, but no preparation needed for this repo"
|
- echo "here I can run custom commands, but no preparation needed for this repo"
|
||||||
|
262
README.md
262
README.md
@ -676,6 +676,12 @@ output:
|
|||||||
|
|
||||||
# all available settings of specific linters
|
# all available settings of specific linters
|
||||||
linters-settings:
|
linters-settings:
|
||||||
|
dogsled:
|
||||||
|
# checks assignments with too many blank identifiers; default is 2
|
||||||
|
max-blank-identifiers: 2
|
||||||
|
dupl:
|
||||||
|
# tokens count to trigger issue, 150 by default
|
||||||
|
threshold: 100
|
||||||
errcheck:
|
errcheck:
|
||||||
# report about not checking of errors in type assetions: `a := b.(MyStruct)`;
|
# report about not checking of errors in type assetions: `a := b.(MyStruct)`;
|
||||||
# default is false: such cases aren't reported by default.
|
# default is false: such cases aren't reported by default.
|
||||||
@ -693,106 +699,17 @@ linters-settings:
|
|||||||
# path to a file containing a list of functions to exclude from checking
|
# path to a file containing a list of functions to exclude from checking
|
||||||
# see https://github.com/kisielk/errcheck#excluding-functions for details
|
# see https://github.com/kisielk/errcheck#excluding-functions for details
|
||||||
exclude: /path/to/file.txt
|
exclude: /path/to/file.txt
|
||||||
|
|
||||||
funlen:
|
funlen:
|
||||||
lines: 60
|
lines: 60
|
||||||
statements: 40
|
statements: 40
|
||||||
|
|
||||||
govet:
|
|
||||||
# report about shadowed variables
|
|
||||||
check-shadowing: true
|
|
||||||
|
|
||||||
# settings per analyzer
|
|
||||||
settings:
|
|
||||||
printf: # analyzer name, run `go tool vet help` to see all analyzers
|
|
||||||
funcs: # run `go tool vet help printf` to see available settings for `printf` analyzer
|
|
||||||
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Infof
|
|
||||||
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Warnf
|
|
||||||
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Errorf
|
|
||||||
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Fatalf
|
|
||||||
|
|
||||||
# enable or disable analyzers by name
|
|
||||||
enable:
|
|
||||||
- atomicalign
|
|
||||||
enable-all: false
|
|
||||||
disable:
|
|
||||||
- shadow
|
|
||||||
disable-all: false
|
|
||||||
golint:
|
|
||||||
# minimal confidence for issues, default is 0.8
|
|
||||||
min-confidence: 0.8
|
|
||||||
gofmt:
|
|
||||||
# simplify code: gofmt with `-s` option, true by default
|
|
||||||
simplify: true
|
|
||||||
goimports:
|
|
||||||
# put imports beginning with prefix after 3rd-party packages;
|
|
||||||
# it's a comma-separated list of prefixes
|
|
||||||
local-prefixes: github.com/org/project
|
|
||||||
gocyclo:
|
|
||||||
# minimal code complexity to report, 30 by default (but we recommend 10-20)
|
|
||||||
min-complexity: 10
|
|
||||||
gocognit:
|
gocognit:
|
||||||
# minimal code complexity to report, 30 by default (but we recommend 10-20)
|
# minimal code complexity to report, 30 by default (but we recommend 10-20)
|
||||||
min-complexity: 10
|
min-complexity: 10
|
||||||
maligned:
|
|
||||||
# print struct with more effective memory layout or not, false by default
|
|
||||||
suggest-new: true
|
|
||||||
dupl:
|
|
||||||
# tokens count to trigger issue, 150 by default
|
|
||||||
threshold: 100
|
|
||||||
goconst:
|
goconst:
|
||||||
# minimal length of string constant, 3 by default
|
# minimal length of string constant, 3 by default
|
||||||
min-len: 3
|
min-len: 3
|
||||||
# minimal occurrences count to trigger, 3 by default
|
# minimal occurrences count to trigger, 3 by default
|
||||||
min-occurrences: 3
|
min-occurrences: 3
|
||||||
depguard:
|
|
||||||
list-type: blacklist
|
|
||||||
include-go-root: false
|
|
||||||
packages:
|
|
||||||
- github.com/sirupsen/logrus
|
|
||||||
packages-with-error-message:
|
|
||||||
# specify an error message to output when a blacklisted package is used
|
|
||||||
- github.com/sirupsen/logrus: "logging is allowed only by logutils.Log"
|
|
||||||
misspell:
|
|
||||||
# Correct spellings using locale preferences for US or UK.
|
|
||||||
# Default is to use a neutral variety of English.
|
|
||||||
# Setting locale to US will correct the British spelling of 'colour' to 'color'.
|
|
||||||
locale: US
|
|
||||||
ignore-words:
|
|
||||||
- someword
|
|
||||||
lll:
|
|
||||||
# max line length, lines longer will be reported. Default is 120.
|
|
||||||
# '\t' is counted as 1 character by default, and can be changed with the tab-width option
|
|
||||||
line-length: 120
|
|
||||||
# tab width in spaces. Default to 1.
|
|
||||||
tab-width: 1
|
|
||||||
rowserrcheck:
|
|
||||||
packages:
|
|
||||||
- github.com/jmoiron/sqlx
|
|
||||||
unused:
|
|
||||||
# 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: false
|
|
||||||
unparam:
|
|
||||||
# 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: false
|
|
||||||
nakedret:
|
|
||||||
# make an issue if func has more lines of code than this setting and it has naked returns; default is 30
|
|
||||||
max-func-lines: 30
|
|
||||||
prealloc:
|
|
||||||
# XXX: we don't recommend using this linter before doing performance profiling.
|
|
||||||
# For most programs usage of prealloc will be a premature optimization.
|
|
||||||
|
|
||||||
# Report preallocation suggestions only on simple loops that have no returns/breaks/continues/gotos in them.
|
|
||||||
# True by default.
|
|
||||||
simple: true
|
|
||||||
range-loops: true # Report preallocation suggestions on range loops, true by default
|
|
||||||
for-loops: false # Report preallocation suggestions on for loops, false by default
|
|
||||||
gocritic:
|
gocritic:
|
||||||
# Which checks should be enabled; can't be combined with 'disabled-checks';
|
# Which checks should be enabled; can't be combined with 'disabled-checks';
|
||||||
# See https://go-critic.github.io/overview#checks-overview
|
# See https://go-critic.github.io/overview#checks-overview
|
||||||
@ -815,6 +732,9 @@ linters-settings:
|
|||||||
paramsOnly: true
|
paramsOnly: true
|
||||||
rangeValCopy:
|
rangeValCopy:
|
||||||
sizeThreshold: 32
|
sizeThreshold: 32
|
||||||
|
gocyclo:
|
||||||
|
# minimal code complexity to report, 30 by default (but we recommend 10-20)
|
||||||
|
min-complexity: 10
|
||||||
godox:
|
godox:
|
||||||
# report any comments starting with keywords, this is useful for TODO or FIXME comments that
|
# report any comments starting with keywords, this is useful for TODO or FIXME comments that
|
||||||
# might be left in the code accidentally and should be resolved before merging
|
# might be left in the code accidentally and should be resolved before merging
|
||||||
@ -822,10 +742,92 @@ linters-settings:
|
|||||||
- NOTE
|
- NOTE
|
||||||
- OPTIMIZE # marks code that should be optimized before merging
|
- OPTIMIZE # marks code that should be optimized before merging
|
||||||
- HACK # marks hack-arounds that should be removed before merging
|
- HACK # marks hack-arounds that should be removed before merging
|
||||||
dogsled:
|
gofmt:
|
||||||
# checks assignments with too many blank identifiers; default is 2
|
# simplify code: gofmt with `-s` option, true by default
|
||||||
max-blank-identifiers: 2
|
simplify: true
|
||||||
|
goimports:
|
||||||
|
# put imports beginning with prefix after 3rd-party packages;
|
||||||
|
# it's a comma-separated list of prefixes
|
||||||
|
local-prefixes: github.com/org/project
|
||||||
|
golint:
|
||||||
|
# minimal confidence for issues, default is 0.8
|
||||||
|
min-confidence: 0.8
|
||||||
|
gomnd:
|
||||||
|
settings:
|
||||||
|
mnd:
|
||||||
|
# the list of enabled checks, see https://github.com/tommy-muehle/go-mnd/#checks for description.
|
||||||
|
checks: argument,case,condition,operation,return,assign
|
||||||
|
govet:
|
||||||
|
# report about shadowed variables
|
||||||
|
check-shadowing: true
|
||||||
|
|
||||||
|
# settings per analyzer
|
||||||
|
settings:
|
||||||
|
printf: # analyzer name, run `go tool vet help` to see all analyzers
|
||||||
|
funcs: # run `go tool vet help printf` to see available settings for `printf` analyzer
|
||||||
|
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Infof
|
||||||
|
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Warnf
|
||||||
|
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Errorf
|
||||||
|
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Fatalf
|
||||||
|
|
||||||
|
# enable or disable analyzers by name
|
||||||
|
enable:
|
||||||
|
- atomicalign
|
||||||
|
enable-all: false
|
||||||
|
disable:
|
||||||
|
- shadow
|
||||||
|
disable-all: false
|
||||||
|
depguard:
|
||||||
|
list-type: blacklist
|
||||||
|
include-go-root: false
|
||||||
|
packages:
|
||||||
|
- github.com/sirupsen/logrus
|
||||||
|
packages-with-error-message:
|
||||||
|
# specify an error message to output when a blacklisted package is used
|
||||||
|
- github.com/sirupsen/logrus: "logging is allowed only by logutils.Log"
|
||||||
|
lll:
|
||||||
|
# max line length, lines longer will be reported. Default is 120.
|
||||||
|
# '\t' is counted as 1 character by default, and can be changed with the tab-width option
|
||||||
|
line-length: 120
|
||||||
|
# tab width in spaces. Default to 1.
|
||||||
|
tab-width: 1
|
||||||
|
maligned:
|
||||||
|
# print struct with more effective memory layout or not, false by default
|
||||||
|
suggest-new: true
|
||||||
|
misspell:
|
||||||
|
# Correct spellings using locale preferences for US or UK.
|
||||||
|
# Default is to use a neutral variety of English.
|
||||||
|
# Setting locale to US will correct the British spelling of 'colour' to 'color'.
|
||||||
|
locale: US
|
||||||
|
ignore-words:
|
||||||
|
- someword
|
||||||
|
nakedret:
|
||||||
|
# make an issue if func has more lines of code than this setting and it has naked returns; default is 30
|
||||||
|
max-func-lines: 30
|
||||||
|
prealloc:
|
||||||
|
# XXX: we don't recommend using this linter before doing performance profiling.
|
||||||
|
# For most programs usage of prealloc will be a premature optimization.
|
||||||
|
|
||||||
|
# Report preallocation suggestions only on simple loops that have no returns/breaks/continues/gotos in them.
|
||||||
|
# True by default.
|
||||||
|
simple: true
|
||||||
|
range-loops: true # Report preallocation suggestions on range loops, true by default
|
||||||
|
for-loops: false # Report preallocation suggestions on for loops, false by default
|
||||||
|
rowserrcheck:
|
||||||
|
packages:
|
||||||
|
- github.com/jmoiron/sqlx
|
||||||
|
unparam:
|
||||||
|
# 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: false
|
||||||
|
unused:
|
||||||
|
# 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: false
|
||||||
whitespace:
|
whitespace:
|
||||||
multi-if: false # Enforces newlines (or comments) after every multi-line if statement
|
multi-if: false # Enforces newlines (or comments) after every multi-line if statement
|
||||||
multi-func: false # Enforces newlines (or comments) after every multi-line function signature
|
multi-func: false # Enforces newlines (or comments) after every multi-line function signature
|
||||||
@ -938,26 +940,6 @@ than the default and have more strict settings:
|
|||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
linters-settings:
|
linters-settings:
|
||||||
govet:
|
|
||||||
check-shadowing: true
|
|
||||||
settings:
|
|
||||||
printf:
|
|
||||||
funcs:
|
|
||||||
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Infof
|
|
||||||
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Warnf
|
|
||||||
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Errorf
|
|
||||||
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Fatalf
|
|
||||||
golint:
|
|
||||||
min-confidence: 0
|
|
||||||
gocyclo:
|
|
||||||
min-complexity: 15
|
|
||||||
maligned:
|
|
||||||
suggest-new: true
|
|
||||||
dupl:
|
|
||||||
threshold: 100
|
|
||||||
goconst:
|
|
||||||
min-len: 2
|
|
||||||
min-occurrences: 2
|
|
||||||
depguard:
|
depguard:
|
||||||
list-type: blacklist
|
list-type: blacklist
|
||||||
packages:
|
packages:
|
||||||
@ -966,12 +948,14 @@ linters-settings:
|
|||||||
- github.com/sirupsen/logrus
|
- github.com/sirupsen/logrus
|
||||||
packages-with-error-message:
|
packages-with-error-message:
|
||||||
- github.com/sirupsen/logrus: "logging is allowed only by logutils.Log"
|
- github.com/sirupsen/logrus: "logging is allowed only by logutils.Log"
|
||||||
misspell:
|
dupl:
|
||||||
locale: US
|
threshold: 100
|
||||||
lll:
|
funlen:
|
||||||
line-length: 140
|
lines: 100
|
||||||
goimports:
|
statements: 50
|
||||||
local-prefixes: github.com/golangci/golangci-lint
|
goconst:
|
||||||
|
min-len: 2
|
||||||
|
min-occurrences: 2
|
||||||
gocritic:
|
gocritic:
|
||||||
enabled-tags:
|
enabled-tags:
|
||||||
- diagnostic
|
- diagnostic
|
||||||
@ -985,16 +969,38 @@ linters-settings:
|
|||||||
- octalLiteral
|
- octalLiteral
|
||||||
- whyNoLint
|
- whyNoLint
|
||||||
- wrapperFunc
|
- wrapperFunc
|
||||||
funlen:
|
gocyclo:
|
||||||
lines: 100
|
min-complexity: 15
|
||||||
statements: 50
|
goimports:
|
||||||
|
local-prefixes: github.com/golangci/golangci-lint
|
||||||
|
golint:
|
||||||
|
min-confidence: 0
|
||||||
|
gomnd:
|
||||||
|
settings:
|
||||||
|
mnd:
|
||||||
|
# don't include the "operation" and "assign"
|
||||||
|
checks: argument,case,condition,return
|
||||||
|
govet:
|
||||||
|
check-shadowing: true
|
||||||
|
settings:
|
||||||
|
printf:
|
||||||
|
funcs:
|
||||||
|
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Infof
|
||||||
|
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Warnf
|
||||||
|
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Errorf
|
||||||
|
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Fatalf
|
||||||
|
lll:
|
||||||
|
line-length: 140
|
||||||
|
maligned:
|
||||||
|
suggest-new: true
|
||||||
|
misspell:
|
||||||
|
locale: US
|
||||||
|
|
||||||
linters:
|
linters:
|
||||||
# please, do not use `enable-all`: it's deprecated and will be removed soon.
|
# 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
|
# inverted configuration with `enable-all` and `disable` is not scalable during updates of golangci-lint
|
||||||
disable-all: true
|
disable-all: true
|
||||||
enable:
|
enable:
|
||||||
# - rowserrcheck
|
|
||||||
- bodyclose
|
- bodyclose
|
||||||
- deadcode
|
- deadcode
|
||||||
- depguard
|
- depguard
|
||||||
@ -1009,6 +1015,8 @@ linters:
|
|||||||
- gofmt
|
- gofmt
|
||||||
- goimports
|
- goimports
|
||||||
- golint
|
- golint
|
||||||
|
# - gomnd TODO: enable it with release > v1.23.0
|
||||||
|
- goprintffuncname
|
||||||
- gosec
|
- gosec
|
||||||
- gosimple
|
- gosimple
|
||||||
- govet
|
- govet
|
||||||
@ -1017,6 +1025,7 @@ linters:
|
|||||||
- lll
|
- lll
|
||||||
- misspell
|
- misspell
|
||||||
- nakedret
|
- nakedret
|
||||||
|
- rowserrcheck
|
||||||
- scopelint
|
- scopelint
|
||||||
- staticcheck
|
- staticcheck
|
||||||
- structcheck
|
- structcheck
|
||||||
@ -1035,6 +1044,13 @@ linters:
|
|||||||
# - maligned
|
# - maligned
|
||||||
# - prealloc
|
# - prealloc
|
||||||
|
|
||||||
|
issues:
|
||||||
|
# Excluding configuration per-path, per-linter, per-text and per-source
|
||||||
|
exclude-rules:
|
||||||
|
- path: _test\.go
|
||||||
|
linters:
|
||||||
|
- gomnd
|
||||||
|
|
||||||
run:
|
run:
|
||||||
skip-dirs:
|
skip-dirs:
|
||||||
- test/testdata_etc
|
- test/testdata_etc
|
||||||
@ -1045,7 +1061,7 @@ run:
|
|||||||
# golangci.com configuration
|
# golangci.com configuration
|
||||||
# https://github.com/golangci/golangci/wiki/Configuration
|
# https://github.com/golangci/golangci/wiki/Configuration
|
||||||
service:
|
service:
|
||||||
golangci-lint-version: 1.22.x # use the fixed version to not introduce new linters unexpectedly
|
golangci-lint-version: 1.23.x # use the fixed version to not introduce new linters unexpectedly
|
||||||
prepare:
|
prepare:
|
||||||
- echo "here I can run custom commands, but no preparation needed for this repo"
|
- echo "here I can run custom commands, but no preparation needed for this repo"
|
||||||
```
|
```
|
||||||
|
@ -5,6 +5,7 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/golangci/golangci-lint/pkg/commands"
|
"github.com/golangci/golangci-lint/pkg/commands"
|
||||||
|
"github.com/golangci/golangci-lint/pkg/exitcodes"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -19,6 +20,6 @@ func main() {
|
|||||||
|
|
||||||
if err := e.Execute(); err != nil {
|
if err := e.Execute(); err != nil {
|
||||||
fmt.Fprintf(os.Stderr, "failed executing command with error %v\n", err)
|
fmt.Fprintf(os.Stderr, "failed executing command with error %v\n", err)
|
||||||
os.Exit(1)
|
os.Exit(exitcodes.Failure)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -210,7 +210,8 @@ func (e *Executor) acquireFileLock() bool {
|
|||||||
ctx, finish := context.WithTimeout(context.Background(), time.Minute)
|
ctx, finish := context.WithTimeout(context.Background(), time.Minute)
|
||||||
defer finish()
|
defer finish()
|
||||||
|
|
||||||
if ok, _ := f.TryLockContext(ctx, time.Second*3); !ok {
|
timeout := time.Second * 3
|
||||||
|
if ok, _ := f.TryLockContext(ctx, timeout); !ok {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,18 +93,23 @@ func printMemStats(ms *runtime.MemStats, logger logutils.Log) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func formatMemory(memBytes uint64) string {
|
func formatMemory(memBytes uint64) string {
|
||||||
if memBytes < 1024 {
|
const Kb = 1024
|
||||||
|
const Mb = Kb * 1024
|
||||||
|
|
||||||
|
if memBytes < Kb {
|
||||||
return fmt.Sprintf("%db", memBytes)
|
return fmt.Sprintf("%db", memBytes)
|
||||||
}
|
}
|
||||||
if memBytes < 1024*1024 {
|
if memBytes < Mb {
|
||||||
return fmt.Sprintf("%dkb", memBytes/1024)
|
return fmt.Sprintf("%dkb", memBytes/Kb)
|
||||||
}
|
}
|
||||||
return fmt.Sprintf("%dmb", memBytes/1024/1024)
|
return fmt.Sprintf("%dmb", memBytes/Mb)
|
||||||
}
|
}
|
||||||
|
|
||||||
func getDefaultConcurrency() int {
|
func getDefaultConcurrency() int {
|
||||||
if os.Getenv("HELP_RUN") == "1" {
|
if os.Getenv("HELP_RUN") == "1" {
|
||||||
return 8 // to make stable concurrency for README help generating builds
|
// Make stable concurrency for README help generating builds.
|
||||||
|
const prettyConcurrency = 8
|
||||||
|
return prettyConcurrency
|
||||||
}
|
}
|
||||||
|
|
||||||
return runtime.NumCPU()
|
return runtime.NumCPU()
|
||||||
|
@ -473,7 +473,9 @@ func watchResources(ctx context.Context, done chan struct{}, logger logutils.Log
|
|||||||
|
|
||||||
var maxRSSMB, totalRSSMB float64
|
var maxRSSMB, totalRSSMB float64
|
||||||
var iterationsCount int
|
var iterationsCount int
|
||||||
ticker := time.NewTicker(100 * time.Millisecond)
|
|
||||||
|
const intervalMS = 100
|
||||||
|
ticker := time.NewTicker(intervalMS * time.Millisecond)
|
||||||
defer ticker.Stop()
|
defer ticker.Stop()
|
||||||
|
|
||||||
logEveryRecord := os.Getenv("GL_MEM_LOG_EVERY") == "1"
|
logEveryRecord := os.Getenv("GL_MEM_LOG_EVERY") == "1"
|
||||||
|
@ -158,6 +158,9 @@ type LintersSettings struct {
|
|||||||
MinStringLen int `mapstructure:"min-len"`
|
MinStringLen int `mapstructure:"min-len"`
|
||||||
MinOccurrencesCount int `mapstructure:"min-occurrences"`
|
MinOccurrencesCount int `mapstructure:"min-occurrences"`
|
||||||
}
|
}
|
||||||
|
Gomnd struct {
|
||||||
|
Settings map[string]map[string]interface{}
|
||||||
|
}
|
||||||
Depguard struct {
|
Depguard struct {
|
||||||
ListType string `mapstructure:"list-type"`
|
ListType string `mapstructure:"list-type"`
|
||||||
Packages []string
|
Packages []string
|
||||||
@ -268,6 +271,7 @@ type WSLSettings struct {
|
|||||||
CaseForceTrailingWhitespaceLimit int `mapstructure:"force-case-trailing-whitespace:"`
|
CaseForceTrailingWhitespaceLimit int `mapstructure:"force-case-trailing-whitespace:"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//nolint:gomnd
|
||||||
var defaultLintersSettings = LintersSettings{
|
var defaultLintersSettings = LintersSettings{
|
||||||
Lll: LllSettings{
|
Lll: LllSettings{
|
||||||
LineLength: 120,
|
LineLength: 120,
|
||||||
@ -360,7 +364,8 @@ func (e ExcludeRule) Validate() error {
|
|||||||
if e.Source != "" {
|
if e.Source != "" {
|
||||||
nonBlank++
|
nonBlank++
|
||||||
}
|
}
|
||||||
if nonBlank < 2 {
|
const minConditionsCount = 2
|
||||||
|
if nonBlank < minConditionsCount {
|
||||||
return errors.New("at least 2 of (text, source, path, linters) should be set")
|
return errors.New("at least 2 of (text, source, path, linters) should be set")
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
@ -27,7 +27,8 @@ func (lc *LineCache) GetLine(filePath string, index1 int) (string, error) {
|
|||||||
index1 = 1
|
index1 = 1
|
||||||
}
|
}
|
||||||
|
|
||||||
rawLine, err := lc.getRawLine(filePath, index1-1)
|
const index1To0Offset = -1
|
||||||
|
rawLine, err := lc.getRawLine(filePath, index1+index1To0Offset)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
@ -432,7 +432,9 @@ func loadIssuesFromCache(pkgs []*packages.Package, lintCtx *linter.Context,
|
|||||||
func runAnalyzers(cfg runAnalyzersConfig, lintCtx *linter.Context) ([]result.Issue, error) {
|
func runAnalyzers(cfg runAnalyzersConfig, lintCtx *linter.Context) ([]result.Issue, error) {
|
||||||
log := lintCtx.Log.Child("goanalysis")
|
log := lintCtx.Log.Child("goanalysis")
|
||||||
sw := timeutils.NewStopwatch("analyzers", log)
|
sw := timeutils.NewStopwatch("analyzers", log)
|
||||||
defer sw.PrintTopStages(10)
|
|
||||||
|
const stagesToPrint = 10
|
||||||
|
defer sw.PrintTopStages(stagesToPrint)
|
||||||
|
|
||||||
runner := newRunner(cfg.getName(), log, lintCtx.PkgCache, lintCtx.LoadGuard, cfg.getLoadMode(), sw)
|
runner := newRunner(cfg.getName(), log, lintCtx.PkgCache, lintCtx.LoadGuard, cfg.getLoadMode(), sw)
|
||||||
|
|
||||||
|
@ -312,7 +312,7 @@ func (r *runner) analyze(pkgs []*packages.Package, analyzers []*analysis.Analyze
|
|||||||
debugf("There are %d initial and %d total packages", len(initialPkgs), len(loadingPackages))
|
debugf("There are %d initial and %d total packages", len(initialPkgs), len(loadingPackages))
|
||||||
for _, lp := range loadingPackages {
|
for _, lp := range loadingPackages {
|
||||||
if lp.isInitial {
|
if lp.isInitial {
|
||||||
wg.Add(1)
|
wg.Add(1) //nolint:gomnd
|
||||||
go func(lp *loadingPackage) {
|
go func(lp *loadingPackage) {
|
||||||
lp.analyzeRecursive(r.loadMode, loadSem)
|
lp.analyzeRecursive(r.loadMode, loadSem)
|
||||||
wg.Done()
|
wg.Done()
|
||||||
|
@ -4,18 +4,24 @@ import (
|
|||||||
mnd "github.com/tommy-muehle/go-mnd"
|
mnd "github.com/tommy-muehle/go-mnd"
|
||||||
"golang.org/x/tools/go/analysis"
|
"golang.org/x/tools/go/analysis"
|
||||||
|
|
||||||
|
"github.com/golangci/golangci-lint/pkg/config"
|
||||||
"github.com/golangci/golangci-lint/pkg/golinters/goanalysis"
|
"github.com/golangci/golangci-lint/pkg/golinters/goanalysis"
|
||||||
)
|
)
|
||||||
|
|
||||||
func NewGoMND() *goanalysis.Linter {
|
func NewGoMND(cfg *config.Config) *goanalysis.Linter {
|
||||||
analyzers := []*analysis.Analyzer{
|
analyzers := []*analysis.Analyzer{
|
||||||
mnd.Analyzer,
|
mnd.Analyzer,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var linterCfg map[string]map[string]interface{}
|
||||||
|
if cfg != nil {
|
||||||
|
linterCfg = cfg.LintersSettings.Gomnd.Settings
|
||||||
|
}
|
||||||
|
|
||||||
return goanalysis.NewLinter(
|
return goanalysis.NewLinter(
|
||||||
"gomnd",
|
"gomnd",
|
||||||
"An analyzer to detect magic numbers.",
|
"An analyzer to detect magic numbers.",
|
||||||
analyzers,
|
analyzers,
|
||||||
nil,
|
linterCfg,
|
||||||
).WithLoadMode(goanalysis.LoadModeSyntax)
|
).WithLoadMode(goanalysis.LoadModeSyntax)
|
||||||
}
|
}
|
||||||
|
@ -166,10 +166,10 @@ func (f *Node) Visit(node ast.Node) ast.Visitor {
|
|||||||
//nolint:interfacer
|
//nolint:interfacer
|
||||||
func (f *Node) errorf(n ast.Node, format string, args ...interface{}) {
|
func (f *Node) errorf(n ast.Node, format string, args ...interface{}) {
|
||||||
pos := f.fset.Position(n.Pos())
|
pos := f.fset.Position(n.Pos())
|
||||||
f.errorfAt(pos, format, args...)
|
f.errorAtf(pos, format, args...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *Node) errorfAt(pos token.Position, format string, args ...interface{}) {
|
func (f *Node) errorAtf(pos token.Position, format string, args ...interface{}) {
|
||||||
*f.issues = append(*f.issues, result.Issue{
|
*f.issues = append(*f.issues, result.Issue{
|
||||||
Pos: pos,
|
Pos: pos,
|
||||||
Text: fmt.Sprintf(format, args...),
|
Text: fmt.Sprintf(format, args...),
|
||||||
|
@ -113,7 +113,7 @@ func (es EnabledSet) combineGoAnalysisLinters(linters map[string]*linter.Config)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(goanalysisLinters) <= 1 {
|
if len(goanalysisLinters) <= 1 { //nolint:gomnd
|
||||||
es.debugf("Didn't combine go/analysis linters: got only %d linters", len(goanalysisLinters))
|
es.debugf("Didn't combine go/analysis linters: got only %d linters", len(goanalysisLinters))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -244,7 +244,7 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config {
|
|||||||
linter.NewConfig(golinters.NewGoPrintfFuncName()).
|
linter.NewConfig(golinters.NewGoPrintfFuncName()).
|
||||||
WithPresets(linter.PresetStyle).
|
WithPresets(linter.PresetStyle).
|
||||||
WithURL("https://github.com/jirfag/go-printf-func-name"),
|
WithURL("https://github.com/jirfag/go-printf-func-name"),
|
||||||
linter.NewConfig(golinters.NewGoMND()).
|
linter.NewConfig(golinters.NewGoMND(m.cfg)).
|
||||||
WithPresets(linter.PresetStyle).
|
WithPresets(linter.PresetStyle).
|
||||||
WithURL("https://github.com/tommy-muehle/go-mnd"),
|
WithURL("https://github.com/tommy-muehle/go-mnd"),
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,7 @@ import (
|
|||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
//nolint:gomnd
|
||||||
func ParseErrorPosition(pos string) (*token.Position, error) {
|
func ParseErrorPosition(pos string) (*token.Position, error) {
|
||||||
// file:line(<optional>:colon)
|
// file:line(<optional>:colon)
|
||||||
parts := strings.Split(pos, ":")
|
parts := strings.Split(pos, ":")
|
||||||
|
@ -1,12 +0,0 @@
|
|||||||
package timeutils
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/golangci/golangci-lint/pkg/logutils"
|
|
||||||
)
|
|
||||||
|
|
||||||
func Track(from time.Time, log logutils.Log, format string, args ...interface{}) {
|
|
||||||
log.Infof("%s took %s", fmt.Sprintf(format, args...), time.Since(from))
|
|
||||||
}
|
|
@ -85,7 +85,7 @@ func errorCheck(outStr string, wantAuto bool, fullshort ...string) (err error) {
|
|||||||
if len(errs) == 0 {
|
if len(errs) == 0 {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if len(errs) == 1 {
|
if len(errs) == 1 { //nolint:gomnd
|
||||||
return errs[0]
|
return errs[0]
|
||||||
}
|
}
|
||||||
var buf bytes.Buffer
|
var buf bytes.Buffer
|
||||||
|
Loading…
x
Reference in New Issue
Block a user