From 3d6d8ffaafc0c5fa22b56001e446532930a5ec92 Mon Sep 17 00:00:00 2001 From: Basil Crow Date: Tue, 5 Oct 2021 10:11:09 -0700 Subject: [PATCH] Enable Warnings Next Generation (#5752) * Fix Javadoc warnings * Enable Warnings Next Generation plugin * Stop recording Maven warnings --- Jenkinsfile | 31 ++++++++++++++++++- core/src/main/java/hudson/FilePath.java | 3 -- .../main/java/hudson/model/UpdateCenter.java | 8 ++--- core/src/main/java/hudson/model/User.java | 2 +- .../slaves/CloudProvisioningListener.java | 9 +++--- .../main/java/hudson/slaves/DumbSlave.java | 7 +++-- .../main/java/hudson/slaves/NodeProperty.java | 9 +++--- .../jenkins/util/io/CompositeIOException.java | 2 +- pom.xml | 1 - 9 files changed, 48 insertions(+), 24 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 2df14f5c26bf..03b504b22bac 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -43,7 +43,7 @@ for(j = 0; j < jdks.size(); j++) { "MAVEN_OPTS=-Xmx1536m -Xms512m"], buildType, jdk) { // Actually run Maven! // -Dmaven.repo.local=… tells Maven to create a subdir in the temporary directory for the local Maven repository - def mvnCmd = "mvn -Pdebug -Pjapicmp -U -Dset.changelist help:evaluate -Dexpression=changelist -Doutput=$changelistF clean install ${runTests ? '-Dmaven.test.failure.ignore' : '-DskipTests'} -V -B -ntp -Dmaven.repo.local=$m2repo -e" + def mvnCmd = "mvn -Pdebug -Pjapicmp -U -Dset.changelist help:evaluate -Dexpression=changelist -Doutput=$changelistF clean install ${runTests ? '-Dmaven.test.failure.ignore' : '-DskipTests'} -V -B -ntp -Dmaven.repo.local=$m2repo -Dspotbugs.failOnError=false -Dcheckstyle.failOnViolation=false -e" if(isUnix()) { sh mvnCmd @@ -66,8 +66,37 @@ for(j = 0; j < jdks.size(); j++) { if (! fileExists('test/target/surefire-reports/TEST-jenkins.Junit4TestsRanTest.xml') ) { error 'junit 4 tests are no longer being run for the test package' } // cli has been migrated to junit 5 + if (failFast && currentBuild.result == 'UNSTABLE') { + error 'There were test failures; halting early' + } } if (buildType == 'Linux' && jdk == jdks[0]) { + def folders = env.JOB_NAME.split('/') + if (folders.length > 1) { + discoverGitReferenceBuild(scm: folders[1]) + } + + echo "Recording static analysis results for '${buildType}'" + recordIssues enabledForFailure: true, + tools: [java(), javaDoc()], + filters: [excludeFile('.*Assert.java')], + sourceCodeEncoding: 'UTF-8', + skipBlames: true, + trendChartType: 'TOOLS_ONLY' + recordIssues([tool: spotBugs(pattern: '**/target/spotbugsXml.xml'), + sourceCodeEncoding: 'UTF-8', + skipBlames: true, + trendChartType: 'TOOLS_ONLY', + qualityGates: [[threshold: 1, type: 'NEW', unstable: true]]]) + recordIssues([tool: checkStyle(pattern: '**/target/checkstyle-result.xml'), + sourceCodeEncoding: 'UTF-8', + skipBlames: true, + trendChartType: 'TOOLS_ONLY', + qualityGates: [[threshold: 1, type: 'TOTAL', unstable: true]]]) + if (failFast && currentBuild.result == 'UNSTABLE') { + error 'Static analysis quality gates not passed; halting early' + } + def changelist = readFile(changelistF) dir(m2repo) { archiveArtifacts artifacts: "**/*$changelist/*$changelist*", diff --git a/core/src/main/java/hudson/FilePath.java b/core/src/main/java/hudson/FilePath.java index a7e37c2bc44e..9c5bb69e044a 100644 --- a/core/src/main/java/hudson/FilePath.java +++ b/core/src/main/java/hudson/FilePath.java @@ -2303,9 +2303,6 @@ public String invoke(File f, VirtualChannel channel) throws IOException, Interru * I/O operations also happens asynchronously from the {@link Channel#call(Callable)} operations, so if * you write to a remote file and then execute {@link Channel#call(Callable)} and try to access the newly copied * file, it might not be fully written yet. - * - *

- * */ public OutputStream write() throws IOException, InterruptedException { if(channel==null) { diff --git a/core/src/main/java/hudson/model/UpdateCenter.java b/core/src/main/java/hudson/model/UpdateCenter.java index a20b2651178f..c30f16dc4d30 100644 --- a/core/src/main/java/hudson/model/UpdateCenter.java +++ b/core/src/main/java/hudson/model/UpdateCenter.java @@ -2116,7 +2116,7 @@ public InstallationJob(Plugin plugin, UpdateSite site, Authentication auth) { } /** - * @deprecated use {@link InstallationJob(Plugin, UpdateSite, Authentication, boolean)} + * @deprecated use {@link #InstallationJob(UpdateSite.Plugin, UpdateSite, Authentication, boolean)} */ @Deprecated public InstallationJob(Plugin plugin, UpdateSite site, org.acegisecurity.Authentication auth, boolean dynamicLoad) { @@ -2342,7 +2342,7 @@ public final class PluginDowngradeJob extends DownloadJob { private final PluginManager pm = Jenkins.get().getPluginManager(); /** - * @deprecated use {@link PluginDowngradeJob(Plugin, UpdateSite, Authentication)} + * @deprecated use {@link #PluginDowngradeJob(UpdateSite.Plugin, UpdateSite, Authentication)} */ @Deprecated public PluginDowngradeJob(Plugin plugin, UpdateSite site, org.acegisecurity.Authentication auth) { @@ -2439,7 +2439,7 @@ public String toString() { public final class HudsonUpgradeJob extends DownloadJob { /** - * @deprecated use {@link HudsonUpgradeJob(UpdateSite site, Authentication auth)} + * @deprecated use {@link #HudsonUpgradeJob(UpdateSite, Authentication)} */ @Deprecated public HudsonUpgradeJob(UpdateSite site, org.acegisecurity.Authentication auth) { @@ -2486,7 +2486,7 @@ protected void replace(File dst, File src) throws IOException { public final class HudsonDowngradeJob extends DownloadJob { /** - * @deprecated use {@link HudsonDowngradeJob(UpdateSite site, Authentication auth)} + * @deprecated use {@link #HudsonDowngradeJob(UpdateSite, Authentication)} */ @Deprecated public HudsonDowngradeJob(UpdateSite site, org.acegisecurity.Authentication auth) { diff --git a/core/src/main/java/hudson/model/User.java b/core/src/main/java/hudson/model/User.java index e5c920394f6a..8c6041ae1399 100644 --- a/core/src/main/java/hudson/model/User.java +++ b/core/src/main/java/hudson/model/User.java @@ -139,7 +139,7 @@ public class User extends AbstractModelObject implements AccessControlled, Descr * Unfortunately this infringed some legitimate use cases of creating Jenkins-local users for * automation purposes. This escape hatch switch can be enabled to resurrect that behaviour. *

- * @see JENKINS-22346. + * See JENKINS-22346. */ @SuppressFBWarnings("MS_SHOULD_BE_FINAL") public static boolean ALLOW_NON_EXISTENT_USER_TO_LOGIN = SystemProperties.getBoolean(User.class.getName() + ".allowNonExistentUserToLogin"); diff --git a/core/src/main/java/hudson/slaves/CloudProvisioningListener.java b/core/src/main/java/hudson/slaves/CloudProvisioningListener.java index bf45cad21d2e..6f1acd5470f3 100644 --- a/core/src/main/java/hudson/slaves/CloudProvisioningListener.java +++ b/core/src/main/java/hudson/slaves/CloudProvisioningListener.java @@ -7,7 +7,6 @@ import hudson.model.Label; import hudson.model.Node; import hudson.model.queue.CauseOfBlockage; -import hudson.slaves.Cloud.CloudState; import java.util.Collection; import java.util.concurrent.Future; import jenkins.model.Jenkins; @@ -36,7 +35,7 @@ public abstract class CloudProvisioningListener implements ExtensionPoint { * @return {@code null} if provisioning can proceed, or a * {@link CauseOfBlockage} reason why it cannot be provisioned. * - * @deprecated Use {@link #canProvision(Cloud, CloudState, int)} instead. + * @deprecated Use {@link #canProvision(Cloud, Cloud.CloudState, int)} )} instead. */ @Deprecated public CauseOfBlockage canProvision(Cloud cloud, Label label, int numExecutors) { @@ -44,9 +43,9 @@ public CauseOfBlockage canProvision(Cloud cloud, Label label, int numExecutors) getClass(), "canProvision", Cloud.class, - CloudState.class, + Cloud.CloudState.class, int.class)) { - return canProvision(cloud, new CloudState(label, 0), numExecutors); + return canProvision(cloud, new Cloud.CloudState(label, 0), numExecutors); } else { return null; } @@ -64,7 +63,7 @@ public CauseOfBlockage canProvision(Cloud cloud, Label label, int numExecutors) * @return {@code null} if provisioning can proceed, or a * {@link CauseOfBlockage} reason why it cannot be provisioned. */ - public CauseOfBlockage canProvision(Cloud cloud, CloudState state, int numExecutors) { + public CauseOfBlockage canProvision(Cloud cloud, Cloud.CloudState state, int numExecutors) { return canProvision(cloud, state.getLabel(), numExecutors); } diff --git a/core/src/main/java/hudson/slaves/DumbSlave.java b/core/src/main/java/hudson/slaves/DumbSlave.java index e06267dc9de1..5f5fef1c10c2 100644 --- a/core/src/main/java/hudson/slaves/DumbSlave.java +++ b/core/src/main/java/hudson/slaves/DumbSlave.java @@ -26,6 +26,7 @@ import edu.umd.cs.findbugs.annotations.NonNull; import hudson.Extension; import hudson.model.Descriptor.FormException; +import hudson.model.Node; import hudson.model.Slave; import java.io.IOException; import java.util.ArrayList; @@ -42,10 +43,10 @@ public final class DumbSlave extends Slave { /** * @deprecated as of 1.286. - * Use {@link #DumbSlave(String, String, String, String, Mode, String, ComputerLauncher, RetentionStrategy, List)} + * Use {@link #DumbSlave(String, String, String, String, Node.Mode, String, ComputerLauncher, RetentionStrategy, List)} */ @Deprecated - public DumbSlave(String name, String nodeDescription, String remoteFS, String numExecutors, Mode mode, String labelString, ComputerLauncher launcher, RetentionStrategy retentionStrategy) throws FormException, IOException { + public DumbSlave(String name, String nodeDescription, String remoteFS, String numExecutors, Node.Mode mode, String labelString, ComputerLauncher launcher, RetentionStrategy retentionStrategy) throws FormException, IOException { this(name, nodeDescription, remoteFS, numExecutors, mode, labelString, launcher, retentionStrategy, new ArrayList()); } @@ -54,7 +55,7 @@ public DumbSlave(String name, String nodeDescription, String remoteFS, String nu * Use {@link #DumbSlave(String, String, ComputerLauncher)} and configure the rest through setters. */ @Deprecated - public DumbSlave(String name, String nodeDescription, String remoteFS, String numExecutors, Mode mode, String labelString, ComputerLauncher launcher, RetentionStrategy retentionStrategy, List> nodeProperties) throws IOException, FormException { + public DumbSlave(String name, String nodeDescription, String remoteFS, String numExecutors, Node.Mode mode, String labelString, ComputerLauncher launcher, RetentionStrategy retentionStrategy, List> nodeProperties) throws IOException, FormException { super(name, nodeDescription, remoteFS, numExecutors, mode, labelString, launcher, retentionStrategy, nodeProperties); } diff --git a/core/src/main/java/hudson/slaves/NodeProperty.java b/core/src/main/java/hudson/slaves/NodeProperty.java index 5025a6d68573..ef9abacc876f 100644 --- a/core/src/main/java/hudson/slaves/NodeProperty.java +++ b/core/src/main/java/hudson/slaves/NodeProperty.java @@ -34,8 +34,7 @@ import hudson.model.Descriptor.FormException; import hudson.model.Environment; import hudson.model.Node; -import hudson.model.Queue.BuildableItem; -import hudson.model.Queue.Task; +import hudson.model.Queue; import hudson.model.ReconfigurableDescribable; import hudson.model.TaskListener; import hudson.model.queue.CauseOfBlockage; @@ -95,10 +94,10 @@ public NodePropertyDescriptor getDescriptor() { * * @since 1.360 * @deprecated as of 1.413 - * Use {@link #canTake(BuildableItem)} + * Use {@link #canTake(Queue.BuildableItem)} */ @Deprecated - public CauseOfBlockage canTake(Task task) { + public CauseOfBlockage canTake(Queue.Task task) { return null; } @@ -110,7 +109,7 @@ public CauseOfBlockage canTake(Task task) { * * @since 1.413 */ - public CauseOfBlockage canTake(BuildableItem item) { + public CauseOfBlockage canTake(Queue.BuildableItem item) { return canTake(item.task); // backward compatible behaviour } diff --git a/core/src/main/java/jenkins/util/io/CompositeIOException.java b/core/src/main/java/jenkins/util/io/CompositeIOException.java index 220c590ac1ee..f72d7e4e303b 100644 --- a/core/src/main/java/jenkins/util/io/CompositeIOException.java +++ b/core/src/main/java/jenkins/util/io/CompositeIOException.java @@ -71,7 +71,7 @@ public CompositeIOException(String message, @NonNull List exception } /** - * @see CompositeIOException(String, List) + * @see #CompositeIOException(String, List) */ public CompositeIOException(String message, IOException... exceptions) { this(message, Arrays.asList(exceptions)); diff --git a/pom.xml b/pom.xml index 6a625b01de5a..fd789cbbfe4d 100644 --- a/pom.xml +++ b/pom.xml @@ -424,7 +424,6 @@ THE SOFTWARE. true - true true