Skip to content

Commit 349bccc

Browse files
jglickclaude
andauthored
Spotless (#372)
* Enable Spotless code formatting Configure the project to use Spotless by setting spotless.check.skip=false. This enables the Spotless Maven plugin inherited from the parent POM. Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> * Apply Spotless code formatting Run mvnd spotless:apply to format all Java and XML files according to the Spotless configuration inherited from the parent POM. Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> * Refine code formatting for better readability Improve comment placement and line breaks introduced by Spotless: - Move inline XML comments to precede the elements they describe - Relocate inline code comments to their own lines before statements - Break comment lines at natural grammatical boundaries - Ensure multi-line comments remain logically grouped Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> * More (manual) edits to improve legibility * Missed a case * Again * Diffs are apparently a lot more legible on GitHub, with syntax highlighting * And a few more --------- Co-authored-by: Claude <[email protected]>
1 parent 86ce923 commit 349bccc

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+1981
-1463
lines changed

pom.xml

Lines changed: 242 additions & 241 deletions
Large diffs are not rendered by default.

src/main/java/org/jenkinsci/plugins/workflow/steps/ArtifactArchiverStep.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ public String getExcludes() {
3636
return excludes;
3737
}
3838

39-
@DataBoundSetter public void setExcludes(String excludes) {
39+
@DataBoundSetter
40+
public void setExcludes(String excludes) {
4041
this.excludes = Util.fixEmptyAndTrim(excludes);
4142
}
4243

@@ -74,6 +75,5 @@ public Set<? extends Class<?>> getRequiredContext() {
7475
Collections.addAll(context, FilePath.class, Run.class, Launcher.class, TaskListener.class);
7576
return Collections.unmodifiableSet(context);
7677
}
77-
7878
}
7979
}

src/main/java/org/jenkinsci/plugins/workflow/steps/ArtifactArchiverStepExecution.java

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,10 @@
66
import hudson.model.Run;
77
import hudson.model.TaskListener;
88
import hudson.remoting.VirtualChannel;
9-
109
import java.io.File;
1110
import java.io.IOException;
1211
import java.util.HashMap;
1312
import java.util.Map;
14-
15-
1613
import jenkins.MasterToSlaveFileCallable;
1714
import jenkins.util.BuildListenerAdapter;
1815

@@ -21,7 +18,7 @@
2118
*/
2219
public class ArtifactArchiverStepExecution extends SynchronousNonBlockingStepExecution<Void> {
2320

24-
private transient final ArtifactArchiverStep step;
21+
private final transient ArtifactArchiverStep step;
2522

2623
ArtifactArchiverStepExecution(ArtifactArchiverStep step, StepContext context) {
2724
super(context);
@@ -36,29 +33,44 @@ protected Void run() throws Exception {
3633
if (listener != null) {
3734
listener.getLogger().println(Messages.ArtifactArchiverStepExecution_Deprecated());
3835
}
39-
Map<String,String> files = ws.act(new ListFiles(step.getIncludes(), step.getExcludes()));
36+
Map<String, String> files = ws.act(new ListFiles(step.getIncludes(), step.getExcludes()));
4037
if (files.isEmpty()) {
4138
if (step.getExcludes() != null && !step.getExcludes().equals("")) {
42-
listener.getLogger().println(Messages.ArtifactArchiverStepExecution_NoFilesWithExcludes(step.getIncludes(), step.getExcludes()));
39+
listener.getLogger()
40+
.println(Messages.ArtifactArchiverStepExecution_NoFilesWithExcludes(
41+
step.getIncludes(), step.getExcludes()));
4342
} else {
4443
listener.getLogger().println(Messages.ArtifactArchiverStepExecution_NoFiles(step.getIncludes()));
4544
}
4645
} else {
47-
getContext().get(Run.class).pickArtifactManager().archive(ws, getContext().get(Launcher.class), new BuildListenerAdapter(getContext().get(TaskListener.class)), files);
46+
getContext()
47+
.get(Run.class)
48+
.pickArtifactManager()
49+
.archive(
50+
ws,
51+
getContext().get(Launcher.class),
52+
new BuildListenerAdapter(getContext().get(TaskListener.class)),
53+
files);
4854
}
4955
return null;
5056
}
5157

52-
private static final class ListFiles extends MasterToSlaveFileCallable<Map<String,String>> {
58+
private static final class ListFiles extends MasterToSlaveFileCallable<Map<String, String>> {
5359
private static final long serialVersionUID = 1;
5460
private final String includes, excludes;
61+
5562
ListFiles(String includes, String excludes) {
5663
this.includes = includes;
5764
this.excludes = excludes;
5865
}
59-
@Override public Map<String,String> invoke(File basedir, VirtualChannel channel) throws IOException, InterruptedException {
60-
Map<String,String> r = new HashMap<>();
61-
for (String f : Util.createFileSet(basedir, includes, excludes).getDirectoryScanner().getIncludedFiles()) {
66+
67+
@Override
68+
public Map<String, String> invoke(File basedir, VirtualChannel channel)
69+
throws IOException, InterruptedException {
70+
Map<String, String> r = new HashMap<>();
71+
for (String f : Util.createFileSet(basedir, includes, excludes)
72+
.getDirectoryScanner()
73+
.getIncludedFiles()) {
6274
f = f.replace(File.separatorChar, '/');
6375
r.put(f, f);
6476
}
@@ -67,5 +79,4 @@ private static final class ListFiles extends MasterToSlaveFileCallable<Map<Strin
6779
}
6880

6981
private static final long serialVersionUID = 1L;
70-
7182
}

src/main/java/org/jenkinsci/plugins/workflow/steps/ArtifactUnarchiverStep.java

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55
import hudson.FilePath;
66
import hudson.model.Run;
77
import hudson.model.TaskListener;
8-
import org.kohsuke.stapler.DataBoundConstructor;
9-
import org.kohsuke.stapler.DataBoundSetter;
108
import java.util.Collections;
119
import java.util.HashSet;
1210
import java.util.Map;
1311
import java.util.Set;
12+
import org.kohsuke.stapler.DataBoundConstructor;
13+
import org.kohsuke.stapler.DataBoundSetter;
1414

1515
/**
1616
* @author Kohsuke Kawaguchi
@@ -19,13 +19,16 @@ public class ArtifactUnarchiverStep extends Step {
1919
/**
2020
* Files to copy over.
2121
*/
22-
@DataBoundSetter public Map<String,String> mapping;
22+
@DataBoundSetter
23+
public Map<String, String> mapping;
2324

2425
// TBD: alternate single-file option value ~ Collections.singletonMap(value, value)
2526

26-
@DataBoundConstructor public ArtifactUnarchiverStep() {}
27+
@DataBoundConstructor
28+
public ArtifactUnarchiverStep() {}
2729

28-
@Override public StepExecution start(StepContext context) throws Exception {
30+
@Override
31+
public StepExecution start(StepContext context) throws Exception {
2932
return new ArtifactUnarchiverStepExecution(mapping, context);
3033
}
3134

@@ -43,16 +46,16 @@ public String getDisplayName() {
4346
return "Copy archived artifacts into the workspace";
4447
}
4548

46-
@Override public boolean isAdvanced() {
49+
@Override
50+
public boolean isAdvanced() {
4751
return true;
4852
}
4953

50-
@Override public Set<? extends Class<?>> getRequiredContext() {
54+
@Override
55+
public Set<? extends Class<?>> getRequiredContext() {
5156
Set<Class<?>> context = new HashSet<>();
5257
Collections.addAll(context, FilePath.class, Run.class, TaskListener.class);
5358
return Collections.unmodifiableSet(context);
5459
}
55-
5660
}
57-
5861
}

src/main/java/org/jenkinsci/plugins/workflow/steps/ArtifactUnarchiverStepExecution.java

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@
66
import hudson.model.Run;
77
import hudson.model.TaskListener;
88
import io.jenkins.plugins.httpclient.RobustHTTPClient;
9-
import jenkins.model.ArtifactManager;
10-
import jenkins.util.VirtualFile;
11-
129
import java.io.IOException;
1310
import java.io.InputStream;
1411
import java.net.URL;
@@ -17,11 +14,13 @@
1714
import java.util.List;
1815
import java.util.Map;
1916
import java.util.Map.Entry;
17+
import jenkins.model.ArtifactManager;
18+
import jenkins.util.VirtualFile;
2019

2120
public class ArtifactUnarchiverStepExecution extends SynchronousNonBlockingStepExecution<List<FilePath>> {
2221

23-
@SuppressFBWarnings(value="SE_TRANSIENT_FIELD_NOT_RESTORED", justification="Only used when starting.")
24-
private transient final Map<String,String> mapping;
22+
@SuppressFBWarnings(value = "SE_TRANSIENT_FIELD_NOT_RESTORED", justification = "Only used when starting.")
23+
private final transient Map<String, String> mapping;
2524

2625
ArtifactUnarchiverStepExecution(Map<String, String> mapping, StepContext context) throws Exception {
2726
super(context);
@@ -66,7 +65,8 @@ protected List<FilePath> run() throws Exception {
6665
return files;
6766
}
6867

69-
private FilePath copy(VirtualFile src, FilePath dst, TaskListener listener) throws IOException, InterruptedException {
68+
private FilePath copy(VirtualFile src, FilePath dst, TaskListener listener)
69+
throws IOException, InterruptedException {
7070
URL u = src.toExternalURL();
7171
if (u != null) {
7272
new RobustHTTPClient().copyFromRemotely(dst, u, listener);
@@ -83,12 +83,11 @@ private FilePath copy(VirtualFile src, FilePath dst, TaskListener listener) thro
8383
*/
8484
private String getFileName(String s) {
8585
int idx = s.lastIndexOf('/');
86-
if (idx>=0) s=s.substring(idx+1);
86+
if (idx >= 0) s = s.substring(idx + 1);
8787
idx = s.lastIndexOf('\\');
88-
if (idx>=0) s=s.substring(idx+1);
88+
if (idx >= 0) s = s.substring(idx + 1);
8989
return s;
9090
}
9191

9292
private static final long serialVersionUID = 1L;
93-
9493
}

src/main/java/org/jenkinsci/plugins/workflow/steps/CatchErrorStep.java

Lines changed: 43 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424

2525
package org.jenkinsci.plugins.workflow.steps;
2626

27+
import edu.umd.cs.findbugs.annotations.CheckForNull;
28+
import edu.umd.cs.findbugs.annotations.NonNull;
2729
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
2830
import hudson.AbortException;
2931
import hudson.Extension;
@@ -39,16 +41,14 @@
3941
import java.util.Collections;
4042
import java.util.HashSet;
4143
import java.util.Set;
42-
import edu.umd.cs.findbugs.annotations.CheckForNull;
43-
import edu.umd.cs.findbugs.annotations.NonNull;
4444
import org.jenkinsci.plugins.workflow.actions.WarningAction;
4545
import org.jenkinsci.plugins.workflow.graph.FlowNode;
4646
import org.kohsuke.stapler.DataBoundConstructor;
4747
import org.kohsuke.stapler.DataBoundSetter;
4848

4949
/**
5050
* Runs a block.
51-
* By default, if that block fails, marks the build as failed, but continues execution. Can be customized to print a
51+
* By default, if that block fails, marks the build as failed, but continues execution. Can be customized to print a
5252
* message when the block fails, to set a different build result, to annotate the step with {@link WarningAction} for
5353
* advanced visualizations, or to rethrow {@link FlowInterruptedException} rather than continuing execution.
5454
*/
@@ -61,7 +61,8 @@ public final class CatchErrorStep extends Step implements CatchExecutionOptions
6161
private @NonNull String stageResult = Result.SUCCESS.toString();
6262
private boolean catchInterruptions = true;
6363

64-
@DataBoundConstructor public CatchErrorStep() {}
64+
@DataBoundConstructor
65+
public CatchErrorStep() {}
6566

6667
@CheckForNull
6768
@Override
@@ -91,7 +92,8 @@ public void setBuildResult(String buildResult) {
9192
buildResult = Result.SUCCESS.toString();
9293
}
9394
if (!buildResult.equalsIgnoreCase(Result.fromString(buildResult).toString())) {
94-
throw new IllegalArgumentException("buildResult is invalid: " + buildResult + ". Valid options are SUCCESS, UNSTABLE, FAILURE, NOT_BUILT and ABORTED.");
95+
throw new IllegalArgumentException("buildResult is invalid: " + buildResult
96+
+ ". Valid options are SUCCESS, UNSTABLE, FAILURE, NOT_BUILT and ABORTED.");
9597
}
9698
this.buildResult = buildResult;
9799
}
@@ -113,7 +115,8 @@ public void setStageResult(String stageResult) {
113115
stageResult = Result.SUCCESS.toString();
114116
}
115117
if (!stageResult.equalsIgnoreCase(Result.fromString(stageResult).toString())) {
116-
throw new IllegalArgumentException("stageResult is invalid: " + stageResult + ". Valid options are SUCCESS, UNSTABLE, FAILURE, NOT_BUILT and ABORTED.");
118+
throw new IllegalArgumentException("stageResult is invalid: " + stageResult
119+
+ ". Valid options are SUCCESS, UNSTABLE, FAILURE, NOT_BUILT and ABORTED.");
117120
}
118121
this.stageResult = stageResult;
119122
}
@@ -132,7 +135,8 @@ private void readObject(ObjectInputStream ois) throws ClassNotFoundException, IO
132135
ObjectInputStream.GetField fields = ois.readFields();
133136
message = (String) fields.get("message", null);
134137
catchInterruptions = fields.get("catchInterruptions", true);
135-
// Previously, the types of buildResult and stageResult were Result rather than String, so we handle either type.
138+
// Previously, the types of buildResult and stageResult were Result rather than String,
139+
// so we handle either type.
136140
Object serializedBuildResult = fields.get("buildResult", "FAILURE");
137141
if (serializedBuildResult instanceof Result) {
138142
buildResult = ((Result) serializedBuildResult).toString();
@@ -147,34 +151,41 @@ private void readObject(ObjectInputStream ois) throws ClassNotFoundException, IO
147151
}
148152
}
149153

150-
@Override public StepExecution start(StepContext context) throws Exception {
154+
@Override
155+
public StepExecution start(StepContext context) throws Exception {
151156
return new Execution(context, this);
152157
}
153158

154-
@Extension public static final class DescriptorImpl extends StepDescriptor {
159+
@Extension
160+
public static final class DescriptorImpl extends StepDescriptor {
155161

156-
@Override public String getFunctionName() {
162+
@Override
163+
public String getFunctionName() {
157164
return "catchError";
158165
}
159166

160167
@NonNull
161-
@Override public String getDisplayName() {
168+
@Override
169+
public String getDisplayName() {
162170
return "Catch error and set build result to failure";
163171
}
164172

165-
@Override public boolean takesImplicitBlockArgument() {
173+
@Override
174+
public boolean takesImplicitBlockArgument() {
166175
return true;
167176
}
168177

169-
@Override public Set<? extends Class<?>> getRequiredContext() {
178+
@Override
179+
public Set<? extends Class<?>> getRequiredContext() {
170180
Set<Class<?>> context = new HashSet<>();
171181
Collections.addAll(context, FlowNode.class, Run.class, TaskListener.class);
172182
return Collections.unmodifiableSet(context);
173183
}
174184

175185
public ListBoxModel doFillBuildResultItems() {
176186
ListBoxModel r = new ListBoxModel();
177-
for (Result result : Arrays.asList(Result.SUCCESS, Result.UNSTABLE, Result.FAILURE, Result.NOT_BUILT, Result.ABORTED)) {
187+
for (Result result :
188+
Arrays.asList(Result.SUCCESS, Result.UNSTABLE, Result.FAILURE, Result.NOT_BUILT, Result.ABORTED)) {
178189
r.add(result.toString());
179190
}
180191
return r;
@@ -183,27 +194,28 @@ public ListBoxModel doFillBuildResultItems() {
183194
public ListBoxModel doFillStageResultItems() {
184195
return doFillBuildResultItems();
185196
}
186-
187197
}
188198

189199
public static final class Execution extends AbstractStepExecutionImpl {
190-
@SuppressFBWarnings(value="SE_TRANSIENT_FIELD_NOT_RESTORED", justification="Only used at startup, serialized in Callback")
191-
private transient final CatchExecutionOptions options;
200+
@SuppressFBWarnings(
201+
value = "SE_TRANSIENT_FIELD_NOT_RESTORED",
202+
justification = "Only used at startup, serialized in Callback")
203+
private final transient CatchExecutionOptions options;
192204

193205
Execution(StepContext context, CatchExecutionOptions options) {
194206
super(context);
195207
this.options = options;
196208
}
197209

198-
@Override public boolean start() throws Exception {
210+
@Override
211+
public boolean start() throws Exception {
199212
StepContext context = getContext();
200-
context.newBodyInvoker()
201-
.withCallback(new Callback(options))
202-
.start();
213+
context.newBodyInvoker().withCallback(new Callback(options)).start();
203214
return false;
204215
}
205216

206-
@Override public void onResume() {}
217+
@Override
218+
public void onResume() {}
207219

208220
private static final class Callback extends BodyExecutionCallback {
209221
private static final long serialVersionUID = -5448044884830236797L;
@@ -220,13 +232,17 @@ public Object readResolve() {
220232
return this;
221233
}
222234

223-
@Override public void onSuccess(StepContext context, Object result) {
235+
@Override
236+
public void onSuccess(StepContext context, Object result) {
224237
context.onSuccess(null); // we do not pass up a result, since onFailure cannot
225238
}
226239

227-
@Override public void onFailure(StepContext context, Throwable t) {
240+
@Override
241+
public void onFailure(StepContext context, Throwable t) {
228242
try {
229-
if (!options.isCatchInterruptions() && t instanceof FlowInterruptedException && ((FlowInterruptedException)t).isActualInterruption()) {
243+
if (!options.isCatchInterruptions()
244+
&& t instanceof FlowInterruptedException
245+
&& ((FlowInterruptedException) t).isActualInterruption()) {
230246
context.onFailure(t);
231247
return;
232248
}
@@ -256,18 +272,17 @@ public Object readResolve() {
256272
build.setResult(buildResult);
257273
}
258274
if (stepResult.isWorseThan(Result.SUCCESS)) {
259-
context.get(FlowNode.class).addOrReplaceAction(new WarningAction(stepResult).withMessage(message));
275+
context.get(FlowNode.class)
276+
.addOrReplaceAction(new WarningAction(stepResult).withMessage(message));
260277
}
261278
context.onSuccess(null);
262279
} catch (Exception x) {
263280
context.onFailure(x);
264281
}
265282
}
266-
267283
}
268284

269285
private static final long serialVersionUID = 1L;
270-
271286
}
272287

273288
private static final CatchExecutionOptions DEFAULT_OPTIONS = new CatchExecutionOptions() {

0 commit comments

Comments
 (0)