forked from gleclaire/findbugs-maven-plugin
-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support multiple bug exclusion files.
Spotbugs always supported multiple files as a comma-separated list in the <excludeFilterFile> configuration option. This change also adds support for multiple files as a list: <excludeFilterFiles> <excludeFilterFile>...</excludeFilterFile> <excludeFilterFile>...</excludeFilterFile> <excludeFilterFiles> This allows using pom inheritance to control multiple files. Includes integration test to verify function.
- Loading branch information
Showing
4 changed files
with
163 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
invoker.goals = clean compile site | ||
|
||
# The expected result of the build, possible values are "success" (default) and "failure" | ||
invoker.buildResult = success |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
Copyright (C) 2006-2020 the original author or authors. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
https://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
--> | ||
|
||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>spotbugs-maven-plugin.it</groupId> | ||
<artifactId>common</artifactId> | ||
<version>testing</version> | ||
<relativePath>../common.xml</relativePath> | ||
</parent> | ||
<artifactId>excludeFile-multi-list</artifactId> | ||
<name>excludeFile-multi-list</name> | ||
<packaging>jar</packaging> | ||
<build> | ||
<extensions> | ||
<extension> | ||
<groupId>spotbugs-maven-plugin.it</groupId> | ||
<artifactId>build-tools</artifactId> | ||
<version>testing</version> | ||
</extension> | ||
</extensions> | ||
</build> | ||
<reporting> | ||
<excludeDefaults>true</excludeDefaults> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-jxr-plugin</artifactId> | ||
<version>@jxrPluginVersion@</version> | ||
</plugin> | ||
<plugin> | ||
<groupId>com.github.spotbugs</groupId> | ||
<artifactId>spotbugs-maven-plugin</artifactId> | ||
<configuration> | ||
<spotbugsXmlOutput>true</spotbugsXmlOutput> | ||
<xmlOutput>true</xmlOutput> | ||
<excludeFilterFiles> | ||
<excludeFilterFile>whizbang/lib-filter.xml</excludeFilterFile> | ||
<excludeFilterFile>filters/lib-filter2.xml</excludeFilterFile> | ||
</excludeFilterFiles> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</reporting> | ||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/* | ||
* Copyright (C) 2006-2020 the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import groovy.xml.XmlSlurper | ||
|
||
File spotbugsHtml = new File(basedir, 'target/site/spotbugs.html') | ||
assert spotbugsHtml.exists() | ||
|
||
File spotbugXdoc = new File(basedir, 'target/spotbugs.xml') | ||
assert spotbugXdoc.exists() | ||
|
||
File spotbugXml = new File(basedir, 'target/spotbugsXml.xml') | ||
assert spotbugXml.exists() | ||
|
||
|
||
println '***************************' | ||
println "Checking HTML file" | ||
println '***************************' | ||
|
||
def xhtmlParser = new XmlSlurper(); | ||
xhtmlParser.setFeature("http://apache.org/xml/features/disallow-doctype-decl", false) | ||
xhtmlParser.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false) | ||
def path = xhtmlParser.parse( spotbugsHtml ) | ||
//*[@id="contentBox"]/div[2]/table/tbody/tr[2]/td[2] | ||
def spotbugsErrors = path.body.'**'.find {div -> div.@id == 'contentBox'}.section[1].table.tr[1].td[1].toInteger() | ||
println "Error Count is ${spotbugsErrors}" | ||
|
||
|
||
println '**********************************' | ||
println "Checking Spotbugs Native XML file" | ||
println '**********************************' | ||
|
||
path = new XmlSlurper().parse(spotbugXml) | ||
|
||
allNodes = path.depthFirst().collect{ it } | ||
def spotbugsXmlErrors = allNodes.findAll {it.name() == 'BugInstance'}.size() | ||
println "BugInstance size is ${spotbugsXmlErrors}" | ||
|
||
|
||
println '***************************' | ||
println "Checking xDoc file" | ||
println '***************************' | ||
|
||
path = new XmlSlurper().parse(spotbugXdoc) | ||
|
||
allNodes = path.depthFirst().collect{ it } | ||
def xdocErrors = allNodes.findAll {it.name() == 'BugInstance'}.size() | ||
println "BugInstance size is ${xdocErrors}" | ||
|
||
|
||
assert xdocErrors == spotbugsXmlErrors | ||
|
||
assert spotbugsErrors == spotbugsXmlErrors |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters