-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
linters/errcheck: add support for ignore/exclude flags #226
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
Conversation
Add support for the exclude and ignore flags of errcheck. Note that, this commit depends on golangci/errcheck#1. We need to merge it first, update vendors and only then merge this one.
|
Any update on this @jirfag? |
|
hi! |
jirfag
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
almost perfect!
pkg/commands/run.go
Outdated
| hideFlag("errcheck.check-blank") | ||
| fs.StringVar(&lsc.Errcheck.Exclude, "errcheck.exclude", "", "errcheck.exclude") | ||
| hideFlag("errcheck.exclude") | ||
| lsc.Errcheck.Ignore = config.IgnoreFlag{} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
set it in defaultLintersSettings please
| fs.BoolVar(&lsc.Errcheck.CheckAssignToBlank, "errcheck.check-blank", false, | ||
| "Errcheck: check for errors assigned to blank identifier: _ = errFunc()") | ||
| hideFlag("errcheck.check-blank") | ||
| fs.StringVar(&lsc.Errcheck.Exclude, "errcheck.exclude", "", "errcheck.exclude") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
flags creation isn't needed: flags above are preserved just for the compatibility with users who use them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO, it makes sense to keep the API compatible for both file and CLI configuration.
| return res, nil | ||
| } | ||
|
|
||
| func genConfig(errCfg *config.ErrcheckSettings) (*errcheckAPI.Config, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Config not declared by package golangci
| } | ||
|
|
||
| func genConfig(errCfg *config.ErrcheckSettings) (*errcheckAPI.Config, error) { | ||
| c := &errcheckAPI.Config{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Config not declared by package golangci
6be582f to
fc41dc7
Compare
pkg/golinters/errcheck.go
Outdated
| } | ||
| scanner := bufio.NewScanner(fh) | ||
| for scanner.Scan() { | ||
| name := scanner.Text() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
declaration of "name" shadows declaration at pkg/golinters/errcheck.go:75
7b548ad to
66f9672
Compare
66f9672 to
97c698f
Compare
|
Hey @jirfag, thanks for the CR. |
|
thank you! |
Follow #223, I've added support for the
excludeandignoreflags of errcheck.Note that, this commit depends on golangci/errcheck#1. We need to merge it first, update vendors and only then merge this one.
Update: all lint errors will disappear after merging golangci/errcheck#1.