gocritic: update default checks list

Update gocritic default checks list, add the current gocritic stable checks list
This commit is contained in:
David López 2018-12-28 09:35:55 +01:00 committed by Isaev Denis
parent 658f4addbd
commit 0192cb3955
3 changed files with 24 additions and 7 deletions

View File

@ -151,9 +151,10 @@ linters-settings:
for-loops: false # Report preallocation suggestions on for loops, false 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';
# default are: [appendAssign assignOp caseOrder dupArg dupBranchBody dupCase flagDeref # default are: [appendAssign appendCombine assignOp builtinShadow captLocal caseOrder defaultCaseOrder
# ifElseChain regexpMust singleCaseSwitch sloppyLen switchTrue typeSwitchVar underef # dupArg dupBranchBody dupCase elseif flagDeref ifElseChain importShadow indexAlloc paramTypeCombine
# unlambda unslice rangeValCopy defaultCaseOrder]; # rangeExprCopy rangeValCopy regexpMust singleCaseSwitch sloppyLen switchTrue typeSwitchVar typeUnparen
# underef unlambda unslice dupSubExpr hugeParam];
# all checks list: https://github.com/go-critic/checkers # all checks list: https://github.com/go-critic/checkers
enabled-checks: enabled-checks:
- rangeValCopy - rangeValCopy

View File

@ -493,6 +493,7 @@ Global Flags:
--cpu-profile-path string Path to CPU profile output file --cpu-profile-path string Path to CPU profile output file
--mem-profile-path string Path to memory profile output file --mem-profile-path string Path to memory profile output file
-v, --verbose verbose output -v, --verbose verbose output
--version Print version
``` ```
@ -667,9 +668,10 @@ linters-settings:
for-loops: false # Report preallocation suggestions on for loops, false 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';
# default are: [appendAssign assignOp caseOrder dupArg dupBranchBody dupCase flagDeref # default are: [appendAssign appendCombine assignOp builtinShadow captLocal caseOrder defaultCaseOrder
# ifElseChain regexpMust singleCaseSwitch sloppyLen switchTrue typeSwitchVar underef # dupArg dupBranchBody dupCase elseif flagDeref ifElseChain importShadow indexAlloc paramTypeCombine
# unlambda unslice rangeValCopy defaultCaseOrder]; # rangeExprCopy rangeValCopy regexpMust singleCaseSwitch sloppyLen switchTrue typeSwitchVar typeUnparen
# underef unlambda unslice dupSubExpr hugeParam];
# all checks list: https://github.com/go-critic/checkers # all checks list: https://github.com/go-critic/checkers
enabled-checks: enabled-checks:
- rangeValCopy - rangeValCopy

View File

@ -257,24 +257,38 @@ func (s GocriticSettings) IsCheckEnabled(name string) bool {
return s.inferredEnabledChecks[strings.ToLower(name)] return s.inferredEnabledChecks[strings.ToLower(name)]
} }
// Its a good idea to keep this list in sync with the gocritic stable checks list in:
// https://github.com/go-critic/go-critic/blob/master/checkers/checkers_test.go#L63
var defaultGocriticEnabledChecks = []string{ var defaultGocriticEnabledChecks = []string{
"appendAssign", "appendAssign",
"appendCombine",
"assignOp", "assignOp",
"builtinShadow",
"captLocal",
"caseOrder", "caseOrder",
"defaultCaseOrder",
"dupArg", "dupArg",
"dupBranchBody", "dupBranchBody",
"dupCase", "dupCase",
"elseif",
"flagDeref", "flagDeref",
"ifElseChain", "ifElseChain",
"importShadow",
"indexAlloc",
"paramTypeCombine",
"rangeExprCopy",
"rangeValCopy",
"regexpMust", "regexpMust",
"singleCaseSwitch", "singleCaseSwitch",
"sloppyLen", "sloppyLen",
"switchTrue", "switchTrue",
"typeSwitchVar", "typeSwitchVar",
"typeUnparen",
"underef", "underef",
"unlambda", "unlambda",
"unslice", "unslice",
"defaultCaseOrder", "dupSubExpr",
"hugeParam",
} }
var defaultLintersSettings = LintersSettings{ var defaultLintersSettings = LintersSettings{