Skip to content

Add support to ignore test files when using errcheck #496

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,7 @@ Flags:
--no-config Don't read config
--skip-dirs strings Regexps of directories to skip
--skip-files strings Regexps of files to skip
--errcheck.without-tests Boolean value to include tests in errcheck or not
-E, --enable strings Enable specific linter
-D, --disable strings Disable specific linter
--enable-all Enable all linters
Expand Down
1 change: 1 addition & 0 deletions pkg/commands/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ func initFlagSet(fs *pflag.FlagSet, cfg *config.Config, m *lintersdb.Manager, is
fs.StringVar(&lsc.Errcheck.Ignore, "errcheck.ignore", "fmt:.*",
`Comma-separated list of pairs of the form pkg:regex. The regex is used to ignore names within pkg`)
hideFlag("errcheck.ignore")
fs.BoolVar(&lsc.Errcheck.WithoutTests, "errcheck.without-tests", false, "Boolean value to include tests in errcheck or not")

fs.BoolVar(&lsc.Govet.CheckShadowing, "govet.check-shadowing", false,
"Govet: check for shadowed variables")
Expand Down
1 change: 1 addition & 0 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ type ErrcheckSettings struct {
CheckAssignToBlank bool `mapstructure:"check-blank"`
Ignore string `mapstructure:"ignore"`
Exclude string `mapstructure:"exclude"`
WithoutTests bool `mapstructure:"without-tests"`
}

type LllSettings struct {
Expand Down
7 changes: 4 additions & 3 deletions pkg/golinters/errcheck.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,10 @@ func genConfig(errCfg *config.ErrcheckSettings) (*errcheckAPI.Config, error) {
}

c := &errcheckAPI.Config{
Ignore: ignoreConfig,
Blank: errCfg.CheckAssignToBlank,
Asserts: errCfg.CheckTypeAssertions,
Ignore: ignoreConfig,
Blank: errCfg.CheckAssignToBlank,
Asserts: errCfg.CheckTypeAssertions,
WithoutTests: errCfg.WithoutTests,
}

if errCfg.Exclude != "" {
Expand Down
9 changes: 6 additions & 3 deletions vendor/github.com/golangci/errcheck/golangci/golangci.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.