Skip to content

Commit

Permalink
Merge pull request #701 from hazendaz/master
Browse files Browse the repository at this point in the history
[cleanup] More defs to actual types
  • Loading branch information
hazendaz authored Dec 17, 2023
2 parents 9bbbfbf + 084cf11 commit 28f601b
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,7 @@ abstract class BaseViolationCheckMojo extends AbstractMojo {
def bug = bugs[i]
int priorityNum = bug.'@priority' as Integer
def priorityName = SpotBugsInfo.spotbugsPriority[priorityNum]
def logMsg = priorityName + ': ' + bug.LongMessage.text() + SpotBugsInfo.BLANK + bug.SourceLine.'@classname' + SpotBugsInfo.BLANK +
String logMsg = priorityName + ': ' + bug.LongMessage.text() + SpotBugsInfo.BLANK + bug.SourceLine.'@classname' + SpotBugsInfo.BLANK +
bug.SourceLine.Message.text() + SpotBugsInfo.BLANK + bug.'@type'

// lower is more severe
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ final class ResourceHelper {
outputResourceFile.getParentFile().mkdirs()
}

def os = new FileOutputStream(outputResourceFile)
FileOutputStream os = new FileOutputStream(outputResourceFile)

os << is

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class SourceFileIndexer {
//String basePath = project.basedir.absolutePath
String basePath = normalizePath(session.getExecutionRootDirectory())

def allSourceFiles = new ArrayList<>()
List<File> allSourceFiles = new ArrayList<>()

// Resource
for (Resource r in project.getResources()) {
Expand Down
10 changes: 5 additions & 5 deletions src/main/groovy/org/codehaus/mojo/spotbugs/SpotBugsGui.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ class SpotBugsGui extends AbstractMojo implements SpotBugsPluginsTrait {
@Override
void execute() {

def ant = new AntBuilder()
AntBuilder ant = new AntBuilder()

def auxClasspathElements = project.compileClasspathElements

Expand All @@ -199,7 +199,7 @@ class SpotBugsGui extends AbstractMojo implements SpotBugsPluginsTrait {

ant.java(classname: "edu.umd.cs.findbugs.LaunchAppropriateUI", fork: "true", failonerror: "true", clonevm: "true", maxmemory: "${maxHeap}m") {

def effectiveEncoding = System.getProperty( "file.encoding", "UTF-8" )
String effectiveEncoding = System.getProperty("file.encoding", "UTF-8")

if ( encoding ) {
effectiveEncoding = encoding
Expand All @@ -213,7 +213,7 @@ class SpotBugsGui extends AbstractMojo implements SpotBugsPluginsTrait {
jvmarg(value: "-Dfindbugs.launchUI=gui2")

// options must be added before the spotbugsXml path
def spotbugsArgs = new ArrayList<String>()
List<String> spotbugsArgs = new ArrayList<>()

spotbugsArgs << getEffortParameter()

Expand All @@ -226,8 +226,8 @@ class SpotBugsGui extends AbstractMojo implements SpotBugsPluginsTrait {
arg(value: spotbugsArg)
}

def spotbugsXmlName = spotbugsXmlOutputDirectory.toString() + "/" + spotbugsXmlOutputFilename
def spotbugsXml = new File(spotbugsXmlName)
String spotbugsXmlName = spotbugsXmlOutputDirectory.toString() + "/" + spotbugsXmlOutputFilename
File spotbugsXml = new File(spotbugsXmlName)

if ( spotbugsXml.exists() ) {
log.debug(" Found an SpotBugs XML at ->" + spotbugsXml.toString())
Expand Down
12 changes: 6 additions & 6 deletions src/main/groovy/org/codehaus/mojo/spotbugs/SpotBugsMojo.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -877,8 +877,8 @@ class SpotBugsMojo extends AbstractMavenReport implements SpotBugsPluginsTrait {
*/
private ArrayList<String> getSpotbugsArgs(File htmlTempFile, File xmlTempFile, File sarifTempFile) {
ResourceHelper resourceHelper = new ResourceHelper(log, spotbugsXmlOutputDirectory, resourceManager)
def args = new ArrayList<String>()
def auxClasspathFile = createSpotbugsAuxClasspathFile()
List<String> args = new ArrayList<>()

if (userPrefs) {
log.debug(" Adding User Preferences File -> ${userPrefs}" )
Expand Down Expand Up @@ -1141,7 +1141,7 @@ class SpotBugsMojo extends AbstractMavenReport implements SpotBugsPluginsTrait {
}
}

def ant = new AntBuilder()
AntBuilder ant = new AntBuilder()

log.info("Fork Value is ${fork}")

Expand All @@ -1151,7 +1151,7 @@ class SpotBugsMojo extends AbstractMavenReport implements SpotBugsPluginsTrait {

def spotbugsArgs = getSpotbugsArgs(htmlTempFile, xmlTempFile, sarifTempFile)

def effectiveEncoding = System.getProperty("file.encoding", "UTF-8")
String effectiveEncoding = System.getProperty("file.encoding", "UTF-8")

if (sourceEncoding) {
effectiveEncoding = sourceEncoding
Expand Down Expand Up @@ -1241,7 +1241,7 @@ class SpotBugsMojo extends AbstractMavenReport implements SpotBugsPluginsTrait {
WrkDir(project.build.directory)
}

def xmlBuilder = new StreamingMarkupBuilder()
StreamingMarkupBuilder xmlBuilder = new StreamingMarkupBuilder()

if (outputFile.exists()) {
outputFile.delete()
Expand Down Expand Up @@ -1274,15 +1274,15 @@ class SpotBugsMojo extends AbstractMavenReport implements SpotBugsPluginsTrait {
if (sarifTempFile && sarifOutput && sarifTempFile.size() > 0) {

def slurpedResult = new JsonSlurper().parse(sarifTempFile)
def builder = new JsonBuilder(slurpedResult)
JsonBuilder builder = new JsonBuilder(slurpedResult)

// With -Dspotbugs.sarifFullPath=true
// The location uri will be replace by path relative to the root of project
// SomeFile.java => src/main/java/SomeFile.java
// This change is required for some tool including Github code scanning API
if (sarifFullPath) {

def indexer = new SourceFileIndexer()
SourceFileIndexer indexer = new SourceFileIndexer()

indexer.buildListSourceFiles(getProject(),getSession())

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ trait SpotBugsPluginsTrait {

URL[] pluginURL

def urlPlugins = ""
String urlPlugins = ""

if (pluginList) {
log.debug(" Adding Plugins ")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -374,11 +374,11 @@ class SpotbugsReportGenerator implements SpotBugsInfo {
return
}

def type = bugInstance.@type.text()
def category = bugInstance.@category.text()
def message = bugInstance.LongMessage.text()
def priority = bugInstance.@priority.text()
def line = bugInstance.SourceLine[0]
String type = bugInstance.@type.text()
String category = bugInstance.@category.text()
String message = bugInstance.LongMessage.text()
String priority = bugInstance.@priority.text()
log.debug("BugInstance message is ${message}")

sink.tableRow()
Expand Down Expand Up @@ -465,7 +465,7 @@ class SpotbugsReportGenerator implements SpotBugsInfo {
}
}

def path = prefix + line.@classname.text().replaceAll("[.]", "/").replaceAll("[\$].*", "")
String path = prefix + line.@classname.text().replaceAll("[.]", "/").replaceAll("[\$].*", "")
String lineNumber = valueForLine(line)

if (lineNumber != bundle.getString(NOLINE_KEY)) {
Expand Down Expand Up @@ -647,8 +647,8 @@ class SpotbugsReportGenerator implements SpotBugsInfo {

spotbugsResults.FindBugsSummary.PackageStats.ClassStats.each() { classStats ->

def classStatsValue = classStats.'@class'.text()
def classStatsBugCount = classStats.'@bugs'.text()
String classStatsValue = classStats.'@class'.text()
String classStatsBugCount = classStats.'@bugs'.text()

if (Integer.parseInt(classStatsBugCount) == 0) {
return
Expand Down Expand Up @@ -712,8 +712,8 @@ class SpotbugsReportGenerator implements SpotBugsInfo {
String value

if (line) {
def startLine = line.@start.text()
def endLine = line.@end.text()
String startLine = line.@start.text()
String endLine = line.@end.text()

if (startLine == endLine) {
if (startLine) {
Expand Down
14 changes: 7 additions & 7 deletions src/main/groovy/org/codehaus/mojo/spotbugs/XDocsReporter.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ class XDocsReporter {

public void generateReport() {

def xmlBuilder = new StreamingMarkupBuilder()
StreamingMarkupBuilder xmlBuilder = new StreamingMarkupBuilder()
xmlBuilder.encoding = "UTF-8"

def xdoc = {
Expand All @@ -164,8 +164,8 @@ class XDocsReporter {

spotbugsResults.FindBugsSummary.PackageStats.ClassStats.each() {classStats ->

def classStatsValue = classStats.'@class'.text()
def classStatsBugCount = classStats.'@bugs'.text()
String classStatsValue = classStats.'@class'.text()
String classStatsBugCount = classStats.'@bugs'.text()

log.debug("classStats...")
log.debug("classStatsValue is ${classStatsValue}")
Expand All @@ -185,11 +185,11 @@ class XDocsReporter {
return
}

def type = bugInstance.@type.text()
def category = bugInstance.@category.text()
def message = bugInstance.LongMessage.text()
def priority = evaluateThresholdParameter(bugInstance.@priority.text())
def line = bugInstance.SourceLine.@start[0].text()
String type = bugInstance.@type.text()
String category = bugInstance.@category.text()
String message = bugInstance.LongMessage.text()
String line = bugInstance.SourceLine.@start[0].text()
log.debug("BugInstance message is ${message}")

BugInstance(type: type, priority: priority, category: category, message: message, lineNumber: ((line) ? line: "-1"))
Expand Down

0 comments on commit 28f601b

Please sign in to comment.