-
Notifications
You must be signed in to change notification settings - Fork 139
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
Ignore comments and empty lines in excludes files #181
Conversation
Another feature that would be helpful is if |
Looks good at initial glance. I will have a more thorough look soon The unmatched pattern reporting is a good idea too, I would probably want to put that behind a flag that can be used to audit the pattern file. |
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.
I noticed a small discrepancy in a test, but LGTM! I tested the change and it appears to work as advertised.
main_test.go
Outdated
func TestReadExcludesFailure(t *testing.T) { | ||
_, err := readExcludes("testdata/notafile") | ||
if err == nil { | ||
t.Fatal("expected nil err, got:", err) |
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.
I think the test actually expects non-nil error?
This change gives uses a way to organize and document exclude entries. This is helpful for large codebases where it isn't obvious why a certain pattern isn't excluded.
I pushed a new commit that a) fixed the buggy test and b) eliminates an errcheck error I accidentally introduced. |
@kisielk did you want hold off on merging this until you have a look? |
Looks good to me. |
I held off integrating errcheck into some projects for a while, because I really didn't want to add more false positives to my linters. The
-exclude
flag gives me a clean way to runerrcheck
and have everyone on the team easily use the same ignore settings.However, if we just add patterns to a file, over time it becomes very difficult to maintain. It isn't always obvious why we want to exclude a certain pattern. Comments and whitespace make it easier to organize the file in large projects.
Comments are also handy when debugging something, because you can temporarily comment something out and see if anything changes.
Note
I wrote this to ignore lines prefixed with
//
. I'm not certain that's better than#
because maybe it could conflict with future pattern recognition features you might add. But, I chose//
anyway since that's what Go uses. I think it would make sense to change it, if someone thinks it might be a problem.