docs: improve goconst documentation. (#2128)
This commit is contained in:
parent
511efdb3cf
commit
245257b8fb
@ -179,8 +179,20 @@ linters-settings:
|
||||
goconst:
|
||||
# minimal length of string constant, 3 by default
|
||||
min-len: 3
|
||||
# minimal occurrences count to trigger, 3 by default
|
||||
# minimum occurrences of constant string count to trigger issue, 3 by default
|
||||
min-occurrences: 3
|
||||
# ignore test files, false by default
|
||||
ignore-tests: false
|
||||
# look for existing constants matching the values, true by default
|
||||
match-constant: true
|
||||
# search also for duplicated numbers, false by default
|
||||
numbers: false
|
||||
# minimum value, only works with goconst.numbers, 3 by default
|
||||
min: 3
|
||||
# maximum value, only works with goconst.numbers, 3 by default
|
||||
max: 3
|
||||
# ignore when constant is not used as function argument, true by default
|
||||
ignore-calls: true
|
||||
|
||||
gocritic:
|
||||
# Which checks should be enabled; can't be combined with 'disabled-checks';
|
||||
|
@ -46,19 +46,23 @@ func NewGoconst() *goanalysis.Linter {
|
||||
}
|
||||
|
||||
func checkConstants(pass *analysis.Pass, lintCtx *linter.Context) ([]goanalysis.Issue, error) {
|
||||
settings := lintCtx.Settings().Goconst
|
||||
|
||||
cfg := goconstAPI.Config{
|
||||
IgnoreTests: lintCtx.Settings().Goconst.IgnoreTests,
|
||||
MatchWithConstants: lintCtx.Settings().Goconst.MatchWithConstants,
|
||||
MinStringLength: lintCtx.Settings().Goconst.MinStringLen,
|
||||
MinOccurrences: lintCtx.Settings().Goconst.MinOccurrencesCount,
|
||||
ParseNumbers: lintCtx.Settings().Goconst.ParseNumbers,
|
||||
NumberMin: lintCtx.Settings().Goconst.NumberMin,
|
||||
NumberMax: lintCtx.Settings().Goconst.NumberMax,
|
||||
IgnoreTests: settings.IgnoreTests,
|
||||
MatchWithConstants: settings.MatchWithConstants,
|
||||
MinStringLength: settings.MinStringLen,
|
||||
MinOccurrences: settings.MinOccurrencesCount,
|
||||
ParseNumbers: settings.ParseNumbers,
|
||||
NumberMin: settings.NumberMin,
|
||||
NumberMax: settings.NumberMax,
|
||||
ExcludeTypes: map[goconstAPI.Type]bool{},
|
||||
}
|
||||
if lintCtx.Settings().Goconst.IgnoreCalls {
|
||||
|
||||
if settings.IgnoreCalls {
|
||||
cfg.ExcludeTypes[goconstAPI.Call] = true
|
||||
}
|
||||
|
||||
goconstIssues, err := goconstAPI.Run(pass.Files, pass.Fset, &cfg)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
Loading…
x
Reference in New Issue
Block a user