-
Notifications
You must be signed in to change notification settings - Fork 53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Miscellaneous code cleanup #399
Conversation
47c8f04
to
105b886
Compare
<exclusion> | ||
<groupId>org.apache.ant</groupId> | ||
<artifactId>ant</artifactId> | ||
</exclusion> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No longer needed, as we removed the only usage of org.apache.tools.ant.filters.StringInputStream
in this PR.
<exclusions> | ||
<exclusion> | ||
<groupId>com.google.code.findbugs</groupId> | ||
<artifactId>jsr305</artifactId> | ||
</exclusion> | ||
</exclusions> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No longer needed, as we switched to SpotBugs annotations in this PR to be consistent with the rest of the Jenkins ecosystem.
@@ -232,7 +232,7 @@ public String getMavenPropertiesFile() { | |||
return mavenPropertiesFile; | |||
} | |||
|
|||
@Nonnull | |||
@NonNull |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Switching to SpotBugs annotations to be consistent with the rest of the Jenkins ecosystem.
@@ -191,7 +191,7 @@ public PluginCompatReport testPlugins() | |||
|
|||
// Scan bundled plugins | |||
// If there is any bundled plugin, only these plugins will be taken under the consideration for the PCT run | |||
UpdateSite.Data data = null; | |||
UpdateSite.Data data; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removing an unnecessary initialization due to the subsequent if/else
block.
@@ -459,7 +459,7 @@ private TestExecutionResult testPluginAgainst(MavenCoordinates coreCoordinates, | |||
System.out.println(String.format("%n%n%n%n%n")); | |||
|
|||
File pluginCheckoutDir = new File(config.workDirectory.getAbsolutePath() + File.separator + plugin.name + File.separator); | |||
String parentFolder = StringUtils.EMPTY; | |||
String parentFolder = ""; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reducing our dependency on Apache Commons Lang. The fewer third-party dependencies, the more maintainable the code.
@@ -27,9 +27,9 @@ | |||
|
|||
import static org.hamcrest.CoreMatchers.equalTo; | |||
import static org.hamcrest.CoreMatchers.is; | |||
import static org.junit.Assert.assertThat; | |||
import static org.hamcrest.MatcherAssert.assertThat; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Migrating from a deprecated method to its non-deprecated equivalent.
@@ -40,7 +40,7 @@ | |||
*/ | |||
public class VersionComparatorTest { | |||
|
|||
private static final ImmutableMap<String, Integer> OPERAND_CONVERSION = ImmutableMap.of( | |||
private static final Map<String, Integer> OPERAND_CONVERSION = Map.of( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reducing our dependency on Guava. The fewer third-party dependencies, the more maintainable the code.
normalizeXmlString(Files.readString(Paths.get(getClass().getResource(resource).toURI()), StandardCharsets.UTF_8)), | ||
normalizeXmlString(FileUtils.readFileToString(pom, StandardCharsets.UTF_8)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reducing our dependency on Apache Commons I/O. The fewer third-party dependencies, the more maintainable the code.
While this was previously using the default character set, this seemed like a bug because our pom.xml
files in Git repositories should always be encoded in UTF-8 (as their XML prologs often declare).
@@ -282,15 +279,15 @@ public void testWithoutAlternativeUrl() throws Throwable { | |||
} | |||
|
|||
@Ignore("TODO broken by GH protocol changes. Requesting user data access via https on local execution") | |||
@Test(expected = Test.None.class) | |||
@Test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removing an unnecessary parameter: Test.None.class
is the default value.
@@ -33,36 +33,36 @@ public void testCheckMethod() { | |||
} | |||
|
|||
@Test | |||
public void testAction() throws Exception { | |||
public void testAction() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removing an unnecessary throws
clause.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good except the potential for a deadlock in the process launching to get the java version
@@ -938,19 +939,19 @@ public static String getMavenModule(String plugin, File pluginPath, MavenRunner | |||
if (absolutePath.endsWith(plugin)) { | |||
return plugin; | |||
} | |||
String module = absolutePath.substring(absolutePath.lastIndexOf(File.separatorChar) + 1, absolutePath.length()); | |||
String module = absolutePath.substring(absolutePath.lastIndexOf(File.separatorChar) + 1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤷 what on earth was it warning about?
src/main/java/org/jenkins/tools/test/model/PluginCompatTesterConfig.java
Outdated
Show resolved
Hide resolved
try { | ||
process.waitFor(); | ||
} catch (InterruptedException e) { | ||
throw new IOException("interrupted while getting Java version", e); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we were not waiting for the process to terminate before trying to read its output.
for good reason see above ;-)
readAllBytes
will block until the end of stream is reached - (ie the process has terminated, or otherwise closed its output stream) thus we can not have partial data.
the argument splitting fix is still valid.
try { | ||
process2.waitFor(); | ||
} catch (InterruptedException e) { | ||
throw new IOException("interrupted while getting full Java version", e); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see similar comment about this and introducing a blocked state.
@@ -166,7 +169,7 @@ public PomData retrievePomData() throws PluginSourcesUnavailableException { | |||
packaging = StringUtils.trimToNull((String)packagingXPath.evaluate(doc, XPathConstants.STRING)); | |||
|
|||
String parentNode = xpath.evaluate("/project/parent", doc); | |||
if (StringUtils.isNotBlank(parentNode)) { | |||
if (parentNode != null && !parentNode.isBlank()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is a common enough idiom here that I wonder if in in hindsight if you had considered introducing a helper class in this module. The two not conditions is not the best for legibility
All feedback is addressed from my perspective - let me know if there are any other changes you would like |
downstream closed source build is passing - this is good to merge from my perspective. |
Fixes IDE warnings and makes the codebase use Java 11 conventions where applicable. While I was here I fixed a minor bug in a call to
ProcessBuilder
, fueled mostly by my recent usage of the same API in a different pull request in this repository (with which the existing code is now consistent). This passed testing injenkinsci/bom
.