Details
Description
It is not possible to utilise a Findbugs excludes filter file when performing analysis of projects. This functionality would have existed in previous versions of Sonar, but was removed as you discussed here - http://old.nabble.com/Sonar-2.5-is-not-honoring-FindBugs-exclussions-filter-defined-in-pom.xml-td30947735.html
Would it be possible to alter the current Findbugs plugin (specifically the FindbugsConfiguration.saveExcludeConfigXml() method) to allow the user to specify an excludes file in the configuration to offer a degree of backwards compatibility?
An example (but untested) fix follows:
public File saveExcludeConfigXml() throws IOException { // Example fix follows: try { String excludesFileLocation = project.getConfiguration().getString("sonar.findbugs.includesFilter"); if (excludesFileLocation != null && !excludesFileLocation.isEmpty()) { File filter = new File(excludesFileLocation); if (filter.exists()) { return filter; } } } catch (NoSuchElementException e) { // log the exception here and proceed as before... } // End of example fix. FindBugsFilter findBugsFilter = new FindBugsFilter(); if (project.getExclusionPatterns() != null) { for (String exclusion : project.getExclusionPatterns()) { ClassFilter classFilter = new ClassFilter(FindbugsAntConverter.antToJavaRegexpConvertor(exclusion)); findBugsFilter.addMatch(new Match(classFilter)); } } return project.getFileSystem().writeToWorkingDirectory(findBugsFilter.toXml(), "findbugs-exclude.xml"); }
We could imagine two provide two features :