errcheck: add an option to remove default exclusions (#2607)
This commit is contained in:
parent
0e7233eb29
commit
2f689958c3
@ -204,6 +204,11 @@ linters-settings:
|
|||||||
# see https://github.com/kisielk/errcheck#the-deprecated-method for details
|
# see https://github.com/kisielk/errcheck#the-deprecated-method for details
|
||||||
ignore: fmt:.*,io/ioutil:^Read.*
|
ignore: fmt:.*,io/ioutil:^Read.*
|
||||||
|
|
||||||
|
# To disable the errcheck built-in exclude list.
|
||||||
|
# See `-excludeonly` option in https://github.com/kisielk/errcheck#excluding-functions for details.
|
||||||
|
# Default: false
|
||||||
|
disable-default-exclusions: true
|
||||||
|
|
||||||
# DEPRECATED use exclude-functions instead.
|
# DEPRECATED use exclude-functions instead.
|
||||||
#
|
#
|
||||||
# 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.
|
||||||
|
@ -215,10 +215,11 @@ type DuplSettings struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type ErrcheckSettings struct {
|
type ErrcheckSettings struct {
|
||||||
CheckTypeAssertions bool `mapstructure:"check-type-assertions"`
|
DisableDefaultExclusions bool `mapstructure:"disable-default-exclusions"`
|
||||||
CheckAssignToBlank bool `mapstructure:"check-blank"`
|
CheckTypeAssertions bool `mapstructure:"check-type-assertions"`
|
||||||
Ignore string `mapstructure:"ignore"`
|
CheckAssignToBlank bool `mapstructure:"check-blank"`
|
||||||
ExcludeFunctions []string `mapstructure:"exclude-functions"`
|
Ignore string `mapstructure:"ignore"`
|
||||||
|
ExcludeFunctions []string `mapstructure:"exclude-functions"`
|
||||||
|
|
||||||
// Deprecated: use ExcludeFunctions instead
|
// Deprecated: use ExcludeFunctions instead
|
||||||
Exclude string `mapstructure:"exclude"`
|
Exclude string `mapstructure:"exclude"`
|
||||||
|
@ -140,10 +140,13 @@ func getChecker(errCfg *config.ErrcheckSettings) (*errcheck.Checker, error) {
|
|||||||
BlankAssignments: !errCfg.CheckAssignToBlank,
|
BlankAssignments: !errCfg.CheckAssignToBlank,
|
||||||
TypeAssertions: !errCfg.CheckTypeAssertions,
|
TypeAssertions: !errCfg.CheckTypeAssertions,
|
||||||
SymbolRegexpsByPackage: map[string]*regexp.Regexp{},
|
SymbolRegexpsByPackage: map[string]*regexp.Regexp{},
|
||||||
Symbols: append([]string{}, errcheck.DefaultExcludedSymbols...),
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !errCfg.DisableDefaultExclusions {
|
||||||
|
checker.Exclusions.Symbols = append(checker.Exclusions.Symbols, errcheck.DefaultExcludedSymbols...)
|
||||||
|
}
|
||||||
|
|
||||||
for pkg, re := range ignoreConfig {
|
for pkg, re := range ignoreConfig {
|
||||||
checker.Exclusions.SymbolRegexpsByPackage[pkg] = re
|
checker.Exclusions.SymbolRegexpsByPackage[pkg] = re
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user