From cf9ebd117ae6f35fc9fd57aae7b90d1a8458a4a7 Mon Sep 17 00:00:00 2001 From: Jeremy Landis Date: Mon, 11 Nov 2024 16:12:54 -0500 Subject: [PATCH 1/2] [ci] Run eclipse formatter against the code --- .../spotbugs/BaseViolationCheckMojo.groovy | 3 +-- .../mojo/spotbugs/ResourceHelper.groovy | 3 --- .../mojo/spotbugs/SourceFileIndexer.groovy | 2 -- .../codehaus/mojo/spotbugs/SpotBugsGui.groovy | 5 ++--- .../mojo/spotbugs/SpotBugsInfo.groovy | 9 +++++++-- .../mojo/spotbugs/SpotBugsMojo.groovy | 19 ++++--------------- .../mojo/spotbugs/SpotBugsPluginsTrait.groovy | 1 - .../spotbugs/SpotbugsReportGenerator.groovy | 1 - .../mojo/spotbugs/XDocsReporter.groovy | 5 ++--- 9 files changed, 16 insertions(+), 32 deletions(-) diff --git a/src/main/groovy/org/codehaus/mojo/spotbugs/BaseViolationCheckMojo.groovy b/src/main/groovy/org/codehaus/mojo/spotbugs/BaseViolationCheckMojo.groovy index e7c6de57..5a8daca7 100644 --- a/src/main/groovy/org/codehaus/mojo/spotbugs/BaseViolationCheckMojo.groovy +++ b/src/main/groovy/org/codehaus/mojo/spotbugs/BaseViolationCheckMojo.groovy @@ -448,7 +448,7 @@ abstract class BaseViolationCheckMojo extends AbstractMojo { sourceFiles.addAll(FileUtils.listFiles(testClassFilesDirectory, SpotBugsInfo.EXTENSIONS, true)) } - log.debug('SourceFiles: ' + Arrays.toString(sourceFiles)); + log.debug('SourceFiles: ' + Arrays.toString(sourceFiles)) !sourceFiles.isEmpty() } @@ -458,5 +458,4 @@ abstract class BaseViolationCheckMojo extends AbstractMojo { log.error(bug.LongMessage.text() + SpotBugsInfo.BLANK + bug.SourceLine.'@classname' + SpotBugsInfo.BLANK + bug.SourceLine.Message.text() + SpotBugsInfo.BLANK + bug.'@type') } } - } diff --git a/src/main/groovy/org/codehaus/mojo/spotbugs/ResourceHelper.groovy b/src/main/groovy/org/codehaus/mojo/spotbugs/ResourceHelper.groovy index 82a66488..9be28d11 100644 --- a/src/main/groovy/org/codehaus/mojo/spotbugs/ResourceHelper.groovy +++ b/src/main/groovy/org/codehaus/mojo/spotbugs/ResourceHelper.groovy @@ -85,7 +85,6 @@ final class ResourceHelper { log.debug('location of resourceFile file is ' + resourceFile.absolutePath) return resourceFile - } private File getResourceAsFile(String name, String outputPath) { @@ -115,12 +114,10 @@ final class ResourceHelper { FileOutputStream os = new FileOutputStream(outputResourceFile) os << is - } catch (IOException e) { throw new FileResourceCreationException('Cannot create file-based resource.', e) } return outputResourceFile } - } diff --git a/src/main/groovy/org/codehaus/mojo/spotbugs/SourceFileIndexer.groovy b/src/main/groovy/org/codehaus/mojo/spotbugs/SourceFileIndexer.groovy index b3073aae..9896ce08 100644 --- a/src/main/groovy/org/codehaus/mojo/spotbugs/SourceFileIndexer.groovy +++ b/src/main/groovy/org/codehaus/mojo/spotbugs/SourceFileIndexer.groovy @@ -100,7 +100,6 @@ class SourceFileIndexer { } } } - } /** @@ -136,5 +135,4 @@ class SourceFileIndexer { // Not found return null } - } diff --git a/src/main/groovy/org/codehaus/mojo/spotbugs/SpotBugsGui.groovy b/src/main/groovy/org/codehaus/mojo/spotbugs/SpotBugsGui.groovy index 49153a20..5cdeb09a 100644 --- a/src/main/groovy/org/codehaus/mojo/spotbugs/SpotBugsGui.groovy +++ b/src/main/groovy/org/codehaus/mojo/spotbugs/SpotBugsGui.groovy @@ -17,8 +17,8 @@ package org.codehaus.mojo.spotbugs import groovy.ant.AntBuilder -import java.nio.charset.Charset; -import java.nio.charset.StandardCharsets; +import java.nio.charset.Charset +import java.nio.charset.StandardCharsets import javax.inject.Inject @@ -188,5 +188,4 @@ class SpotBugsGui extends AbstractMojo implements SpotBugsPluginsTrait { } } } - } diff --git a/src/main/groovy/org/codehaus/mojo/spotbugs/SpotBugsInfo.groovy b/src/main/groovy/org/codehaus/mojo/spotbugs/SpotBugsInfo.groovy index f075e643..2799500b 100644 --- a/src/main/groovy/org/codehaus/mojo/spotbugs/SpotBugsInfo.groovy +++ b/src/main/groovy/org/codehaus/mojo/spotbugs/SpotBugsInfo.groovy @@ -46,7 +46,7 @@ interface SpotBugsInfo { static final String JAVA_SOURCES_KEY = 'report.spotbugs.javasources' /** The extensions to search files for. */ - static final String[] EXTENSIONS = [ 'class' ] + static final String[] EXTENSIONS = ['class'] /** The comma character. */ static final String COMMA = ',' @@ -82,5 +82,10 @@ interface SpotBugsInfo { Map spotbugsThresholds = [High: 'high', Exp: 'experimental', Low: 'low', Medium: 'medium', Default: 'medium'] /** The spotbugs priority as unknown, high, medium, and low. */ - List spotbugsPriority = ['unknown', 'High', 'Medium', 'Low'] + List spotbugsPriority = [ + 'unknown', + 'High', + 'Medium', + 'Low' + ] } diff --git a/src/main/groovy/org/codehaus/mojo/spotbugs/SpotBugsMojo.groovy b/src/main/groovy/org/codehaus/mojo/spotbugs/SpotBugsMojo.groovy index b5f0c395..730ff8ad 100644 --- a/src/main/groovy/org/codehaus/mojo/spotbugs/SpotBugsMojo.groovy +++ b/src/main/groovy/org/codehaus/mojo/spotbugs/SpotBugsMojo.groovy @@ -19,7 +19,7 @@ import groovy.ant.AntBuilder import groovy.json.JsonBuilder import groovy.json.JsonSlurper import groovy.xml.XmlSlurper -import groovy.xml.slurpersupport.GPathResult; +import groovy.xml.slurpersupport.GPathResult import groovy.xml.StreamingMarkupBuilder import org.apache.maven.doxia.siterenderer.Renderer @@ -37,7 +37,7 @@ import org.codehaus.plexus.resource.ResourceManager import org.codehaus.plexus.resource.loader.FileResourceLoader import java.nio.charset.Charset -import java.nio.charset.StandardCharsets; +import java.nio.charset.StandardCharsets import java.nio.file.Files import java.nio.file.Paths import java.util.stream.Collectors @@ -369,7 +369,7 @@ class SpotBugsMojo extends AbstractMavenReport implements SpotBugsPluginsTrait { * @since 4.8.3.0 includes classifier */ @Parameter - PluginArtifact[] plugins; + PluginArtifact[] plugins /** * Restrict analysis to the given comma-separated list of classes and packages. @@ -717,7 +717,6 @@ class SpotBugsMojo extends AbstractMavenReport implements SpotBugsPluginsTrait { xDocsReporter.generateReport() } - } /** @@ -803,7 +802,7 @@ class SpotBugsMojo extends AbstractMavenReport implements SpotBugsPluginsTrait { } if (htmlOutput) { - args << '-html=' + htmlTempFile.getAbsolutePath() + args << '-html=' + htmlTempFile.getAbsolutePath() } args << '-xml:withMessages=' + xmlTempFile.getAbsolutePath() @@ -870,7 +869,6 @@ class SpotBugsMojo extends AbstractMavenReport implements SpotBugsPluginsTrait { args << '-include' args << resourceHelper.getResourceFile(includefilter.trim()) } - } if (includeFilterFiles) { @@ -880,7 +878,6 @@ class SpotBugsMojo extends AbstractMavenReport implements SpotBugsPluginsTrait { args << '-include' args << resourceHelper.getResourceFile(includefilter.trim()) } - } if (excludeFilterFile) { @@ -891,7 +888,6 @@ class SpotBugsMojo extends AbstractMavenReport implements SpotBugsPluginsTrait { args << '-exclude' args << resourceHelper.getResourceFile(excludeFilter.trim()) } - } if (excludeFilterFiles) { @@ -901,7 +897,6 @@ class SpotBugsMojo extends AbstractMavenReport implements SpotBugsPluginsTrait { args << '-exclude' args << resourceHelper.getResourceFile(excludeFilter.trim()) } - } if (excludeBugsFile) { @@ -1109,7 +1104,6 @@ class SpotBugsMojo extends AbstractMavenReport implements SpotBugsPluginsTrait { log.debug("System property ${sysProp.key} is ${sysProp.value}") sysproperty(key: sysProp.key, value: sysProp.value) } - } long duration @@ -1182,7 +1176,6 @@ class SpotBugsMojo extends AbstractMavenReport implements SpotBugsPluginsTrait { if (!log.isDebugEnabled()) { xmlTempFile.delete() } - } if (sarifTempFile && sarifOutput && sarifTempFile.size() > 0) { @@ -1218,7 +1211,6 @@ class SpotBugsMojo extends AbstractMavenReport implements SpotBugsPluginsTrait { + 'The path include in the SARIF report could be incomplete.') } } - } } @@ -1233,7 +1225,6 @@ class SpotBugsMojo extends AbstractMavenReport implements SpotBugsPluginsTrait { sarifTempFile.delete() } } - } /** @@ -1272,7 +1263,6 @@ class SpotBugsMojo extends AbstractMavenReport implements SpotBugsPluginsTrait { log.debug("thresholdParameter is ${thresholdParameter}") return thresholdParameter - } /** @@ -1285,5 +1275,4 @@ class SpotBugsMojo extends AbstractMavenReport implements SpotBugsPluginsTrait { super.setReportOutputDirectory(reportOutputDirectory) this.outputDirectory = reportOutputDirectory } - } diff --git a/src/main/groovy/org/codehaus/mojo/spotbugs/SpotBugsPluginsTrait.groovy b/src/main/groovy/org/codehaus/mojo/spotbugs/SpotBugsPluginsTrait.groovy index 7057fe6a..69b57e05 100644 --- a/src/main/groovy/org/codehaus/mojo/spotbugs/SpotBugsPluginsTrait.groovy +++ b/src/main/groovy/org/codehaus/mojo/spotbugs/SpotBugsPluginsTrait.groovy @@ -144,5 +144,4 @@ trait SpotBugsPluginsTrait { return "-effort:" + effortParameter } - } diff --git a/src/main/groovy/org/codehaus/mojo/spotbugs/SpotbugsReportGenerator.groovy b/src/main/groovy/org/codehaus/mojo/spotbugs/SpotbugsReportGenerator.groovy index f70ffef6..c6887e9d 100644 --- a/src/main/groovy/org/codehaus/mojo/spotbugs/SpotbugsReportGenerator.groovy +++ b/src/main/groovy/org/codehaus/mojo/spotbugs/SpotbugsReportGenerator.groovy @@ -638,5 +638,4 @@ class SpotbugsReportGenerator implements SpotBugsInfo { return value } - } diff --git a/src/main/groovy/org/codehaus/mojo/spotbugs/XDocsReporter.groovy b/src/main/groovy/org/codehaus/mojo/spotbugs/XDocsReporter.groovy index 5430694a..44157382 100644 --- a/src/main/groovy/org/codehaus/mojo/spotbugs/XDocsReporter.groovy +++ b/src/main/groovy/org/codehaus/mojo/spotbugs/XDocsReporter.groovy @@ -20,7 +20,7 @@ import edu.umd.cs.findbugs.Version import groovy.xml.slurpersupport.GPathResult import groovy.xml.StreamingMarkupBuilder -import java.nio.charset.StandardCharsets; +import java.nio.charset.StandardCharsets import org.apache.maven.plugin.logging.Log @@ -163,7 +163,7 @@ class XDocsReporter { spotbugsResults.BugInstance.each() { bugInstance -> if (bugInstance.Class.find{ it.@primary == "true" }.@classname.text() != bugClass) { - return + return } String type = bugInstance.@type.text() @@ -215,5 +215,4 @@ class XDocsReporter { outputWriter << xmlBuilder.bind(xdoc) outputWriter.close() } - } From 1b6f4bf162e0962a7399e138f7323435e2aefe6b Mon Sep 17 00:00:00 2001 From: Jeremy Landis Date: Mon, 11 Nov 2024 16:15:37 -0500 Subject: [PATCH 2/2] [ci] Gstring to string --- src/main/groovy/org/codehaus/mojo/spotbugs/SpotBugsGui.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/groovy/org/codehaus/mojo/spotbugs/SpotBugsGui.groovy b/src/main/groovy/org/codehaus/mojo/spotbugs/SpotBugsGui.groovy index 5cdeb09a..87e70fe1 100644 --- a/src/main/groovy/org/codehaus/mojo/spotbugs/SpotBugsGui.groovy +++ b/src/main/groovy/org/codehaus/mojo/spotbugs/SpotBugsGui.groovy @@ -149,7 +149,7 @@ class SpotBugsGui extends AbstractMojo implements SpotBugsPluginsTrait { log.info('File Encoding is ' + effectiveEncoding.name()) - sysproperty(key: "file.encoding" , value: effectiveEncoding.name()) + sysproperty(key: 'file.encoding' , value: effectiveEncoding.name()) // spotbugs assumes that multiple arguments (because of options) means text mode, so need to request gui explicitly jvmarg(value: '-Dfindbugs.launchUI=gui2')