spotbugs / spotbugs-gradle-plugin

https://plugins.gradle.org/plugin/com.github.spotbugs
Apache License 2.0
180 stars 68 forks source link

PatternFilterable not working #151

Open Vampire opened 5 years ago

Vampire commented 5 years ago

As far as I could determine, using the PatternFilterable methods like exclude and include has no effect at all. I also see nowhere documented how to include or exclude files from analysis. I found in an issue, that you can use classes = classes.filter { ... } to filter the class files.

It would be nice if the documentation would get some bits about how to include / exclude files (from analysis, not with the spotbugs exclude filter file which is only applied after the actual analysis).

And it would be much nicer if the PatternFilterable methods would work, otherwise it is very confusing that PatternFilterable is implemented. At the very least, please make those methods immediately throw an exception if they don't have an effect actually.

The PMD plugin for example supports some of the PatternFilterable methods (the ones taking an Ant pattern) and the others (like exclude { ... }) fail the build if you use them.

jscancella commented 3 years ago

@Vampire is this still an issue?

Vampire commented 3 years ago

Well, it is kind of anti-fixed. The possibility to exclude was completely removed. :-(

jscancella commented 3 years ago

@Vampire I guess I am confused, are we not talking about the onlyAnalyze filter in the new plugin? Example: onlyAnalyze = ['com.foobar.MyClass', 'com.foobar.mypkg.*']. You could also use the <class> element in the excludeFilter = file('spotbugs-exclude.xml') see https://spotbugs.readthedocs.io/en/latest/filter.html

Vampire commented 3 years ago

The old plugin (2.0.0 for example) was PatternFilterable, so it should have worked to use the standard exclude and include to exclude and include files to be analyzed, but they were just ignored.

excludeFilter just works after the analysis was done, so it is a waste of time, as all the generated files have to be analyzed just to then exclude the findings for them in the result.

onlyAnalyze I just have found too, but it is an include filter, not an exclude filter. So I would need to calculate all classes, and then subtract the the generated classes to set up this property instead of being able to simple exclude the generated classes.