If you are using Findbugs for compiled code inspection, is it possible to fail a build based on the result of a single detector or category of detectors?
For example, I would like to ensure that I don't have any null pointer-related detections (prefix of "NP" in this list) of any priority. Likewise, we really don't want to have any wait not in loop situations. That said, I don't necessarily want to fail a build based on internationalization detections as those aren't immediately critical to our application.
The desire开发者_如何学运维d end-state would be a process that we could tune for a variety of development phases ranging from the IDE level (Eclipse and Netbeans) to the release level (builds are generated using CruiseControl).
NOTE: I am aware that Eclipse and Netbeans both have similar detection methods built-in but this is a FindBugs specific question.
From the FindBugs Using the Ant Task section:
includeFilter
Optional attribute. It specifies the filename of a filter specifying which bugs are reported. See Chapter 8, Filter Files.
From Chapter 8:
However, a filter could also be used to select bug instances to specifically report:
$ findbugs -textui -include myIncludeFilter.xml myApp.jar
and
- Match certain tests from all classes by specifying their abbreviations.
<Match>
<Bug code="DE,UrF,SIC" />
</Match></pre>
So I would assume something along the lines of:
<Match>
<Bug code="Wa,NP" />
</Match>
In your include filter and
<findbugs includeFilter="path/to/includefilter.xml"...
Would be what you're looking for.
The path/to /includeFilter
(or excludeFilter
) could be a property that gets set based on the value of another property which could default to something like dev
for regular builds, test
for CI builds, and deploy
for deployment builds and specify which specific warnings you want to see or don't want to see at each stage.
Hope that helps.
精彩评论