-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #635 from Rahul-khandelwal/spotbugs
Add support to load onlyAnalyze classes/packages from specified file.
- Loading branch information
Showing
6 changed files
with
149 additions
and
1 deletion.
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
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,20 @@ | ||
# | ||
# Copyright 2005-2023 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. | ||
# | ||
|
||
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 @@ | ||
BC_Unconfirmed_Cast |
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,51 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
Copyright 2005-2023 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>onlyAnalyzeFileSource</artifactId> | ||
<name>onlyAnalyzeFileSource</name> | ||
<packaging>jar</packaging> | ||
<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> | ||
<onlyAnalyze>file:only-analyze.txt</onlyAnalyze> | ||
</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,69 @@ | ||
/* | ||
* Copyright 2005-2023 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 | ||
|
||
def effortLevel = 'default' | ||
|
||
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 '***************************' | ||
|
||
assert spotbugsHtml.text.contains( "<i>" + effortLevel + "</i>" ) | ||
|
||
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