Here is the patch
Few explications because it is a bit tricky and you might not agree with the choices we made.
Findbugs takes an xml file (excludeFilterFile) for its exclusion. This file has the same pattern as the includeFilterFile
The class name parameter can take a java regexp if it begins with '~'
The problem is that Sonar takes a ant pattern for exclusion
I created a converter from ant pattern to java regexp, it's a bit dirty but it does the trick.
Basically, it iterates over each character of the pattern and replace :
- ? with .
- * with [^\\^\s]* (every character except spaces and \ )
- ** with .*
- \ with . (since findbugs takes classes and not path)
Moreover, if the pattern begin with *\ or **\, it is made optional. Thus :
*\ at the begining of a pattern is replaced by ([^\\^\s]*\.)?
**\ at the begining of a pattern is replaced by (.*\.)?
This exception is for patterns like
The users except that all packages like org.apache.* to be filtered.
Without this exception, the regexp would be
And thus, all packages like org.apache.* would be ignored, since it doesn't start with '.'
I think it is a bit borderline but this exception has reasons.
IMHO, it is more correct to enter something like org/apache/** but since it is used for Pmd or Checkstyle and use path file and not classes, it is simpler to adapt the interpretation for findbugs.