kisielk / errcheck

errcheck checks that you checked errors.
MIT License
2.36k stars 138 forks source link

Add support to exclude by file regexp #253

Open tzvatot opened 3 months ago

tzvatot commented 3 months ago

I want to be able to exclude the linter for files ending with "_test.go" suffix. Is there a way to do it? is there a regexp exclusion support/

dtcaciuc commented 1 month ago

There's no existing feature and nothing like that is planned at the moment. Use of a regex or glob for this purpose can easily misfire and unintentionally mute errors in new files that are added after the exclusion is introduced. See similar issue here https://github.com/kisielk/errcheck/issues/250

I'm surprised you're trying to exclude test files where I would expect you want to check any and all errors? 🤔

dtcaciuc commented 1 month ago

Actually, I didn't realize we do have a feature which should let you accomplish what you want. From the README:

The -ignoretests flag disables checking of _test.go files. It takes no arguments

Does that work for you?