kisielk/errcheck

Add additional Analyzer flag for exclusion patterns

kevinconaway opened this issue · 4 comments

@kisielk we currently use errcheck as an Analyzer as part of the nogo bazel build rule.

As of now, the only way to pass in a list of pattern exclusions is in a file via the exclude flag. Unfortunately, hard coded paths like are very difficult to use with nogo+bazel.

We'd like to see if an additional option could be added to pass the exclude patterns as a list directly in an argument, like -excludepatterns fmt.Printf,fmt.Println

This seems similar to the now deprecated -ignore value but I believe that used regular expressions for the values instead of straight patterns.

I see there was some discussion in the original issue that spawned the exclude functionality about doing this directly on the command line but I'd like to revisit this if we can.

If you agree on the approach I am happy to do the work

That seems like it could work but I didn't do it that way originally because of concerns around limits of command line length. How about the alternative of using a temporary file?

How about the alternative of using a temporary file?

Would you help me understand how a temporary file would work whereas a regular file does not? The issue here is mostly bazel in that it really does not like dealing with full paths so I'm not sure how we would get the path of the temporary file to pass to the analyzer

I see, I'm not familiar with bazel so I thought the issue of "hardcoded paths" was just not being able to reference particular files, but that something like temporaries could be generated during the build process. If the maximum command line length limitation is not going to be an issue I don't have a problem with adding an option to pass excludes as a flag of comma-separated entries.

bazel in that it really does not like dealing with full paths

Could you clarify what "full" path means here? Is the difficulty here not knowing where "cd" is when bazel runs the analyzer? Surely you can reference a relative path to the exclusion file in analyzer_flags?