spotbugs-gradle-plugin icon indicating copy to clipboard operation
spotbugs-gradle-plugin copied to clipboard

PatternFilterable not working

Open Vampire opened this issue 6 years ago • 4 comments

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.

Vampire avatar Jun 06 '19 16:06 Vampire

@Vampire is this still an issue?

jscancella avatar Mar 29 '21 14:03 jscancella

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

Vampire avatar Apr 08 '21 02:04 Vampire

@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

jscancella avatar Apr 08 '21 11:04 jscancella

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.

Vampire avatar Apr 08 '21 11:04 Vampire