Skip to content
This repository was archived by the owner on Mar 27, 2025. It is now read-only.

Commit 11259b8

Browse files
run default java formatter (#382)
1 parent e2ea2bb commit 11259b8

File tree

75 files changed

+1514
-1411
lines changed

Some content is hidden

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

75 files changed

+1514
-1411
lines changed

src/main/java/com/mathworks/ci/BuildArtifactAction.java

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
/**
44
* Copyright 2024 The MathWorks, Inc.
5-
*
65
*/
76

87
import hudson.FilePath;
@@ -36,16 +35,16 @@ public BuildArtifactAction(Run<?, ?> build, String actionID) {
3635
this.actionID = actionID;
3736

3837
// Setting the counts of task when Action is created.
39-
try{
38+
try {
4039
setCounts();
4140
} catch (ParseException e) {
4241
throw new RuntimeException(e);
43-
} catch (InterruptedException e){
42+
} catch (InterruptedException e) {
4443
throw new RuntimeException(e);
4544
}
4645
}
4746

48-
public String getActionID(){
47+
public String getActionID() {
4948
return (this.actionID == null) ? "" : this.actionID;
5049
}
5150

@@ -64,13 +63,13 @@ public String getDisplayName() {
6463
@CheckForNull
6564
@Override
6665
public String getUrlName() {
67-
return (this.actionID == null) ? "buildresults" : "buildresults" + this.actionID ;
66+
return (this.actionID == null) ? "buildresults" : "buildresults" + this.actionID;
6867
}
6968

7069
public List<BuildArtifactData> getBuildArtifact() throws ParseException, InterruptedException, IOException {
7170
List<BuildArtifactData> artifactData = new ArrayList<BuildArtifactData>();
7271
FilePath fl;
73-
if(this.actionID == null){
72+
if (this.actionID == null) {
7473
fl = new FilePath(new File(build.getRootDir().getAbsolutePath() + "/" +
7574
MatlabBuilderConstants.BUILD_ARTIFACT + ".json"));
7675
} else {
@@ -147,7 +146,7 @@ public void setOwner(Run owner) {
147146
private void setCounts() throws InterruptedException, ParseException {
148147
List<BuildArtifactData> artifactData = new ArrayList<BuildArtifactData>();
149148
FilePath fl;
150-
if(this.actionID == null){
149+
if (this.actionID == null) {
151150
fl = new FilePath(new File(build.getRootDir().getAbsolutePath() + "/" +
152151
MatlabBuilderConstants.BUILD_ARTIFACT + ".json"));
153152
} else {
@@ -206,11 +205,11 @@ private void setCounts() throws InterruptedException, ParseException {
206205
private void iterateAllTaskAttributes(Entry pair, BuildArtifactData data) {
207206
// Iterates across all task attributes and updates
208207
String key = pair.getKey().toString();
209-
switch(key){
208+
switch (key) {
210209
case "duration":
211210
data.setTaskDuration(pair.getValue().toString());
212211
break;
213-
case "name" :
212+
case "name":
214213
data.setTaskName(pair.getValue().toString());
215214
break;
216215
case "description":
@@ -225,7 +224,7 @@ private void iterateAllTaskAttributes(Entry pair, BuildArtifactData data) {
225224
case "skipReason":
226225
String skipReasonKey = pair.getValue().toString();
227226
String skipReason;
228-
switch(skipReasonKey){
227+
switch (skipReasonKey) {
229228
case "UpToDate":
230229
skipReason = "up-to-date";
231230
break;
@@ -242,7 +241,7 @@ private void iterateAllTaskAttributes(Entry pair, BuildArtifactData data) {
242241
}
243242
data.setSkipReason(skipReason);
244243
break;
245-
default :
244+
default:
246245
break;
247246
}
248247
}

src/main/java/com/mathworks/ci/BuildArtifactData.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
/**
44
* Copyright 2024 The MathWorks, Inc.
5-
*
65
*/
76

87
public class BuildArtifactData {

src/main/java/com/mathworks/ci/BuildConsoleAnnotator.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
/**
44
* Copyright 2024 The MathWorks, Inc.
5-
*
65
*/
76

87
import com.google.common.base.Charsets;
@@ -39,7 +38,7 @@ private static byte[][] createBuildNotes() {
3938
ByteArrayOutputStream targetNote = new ByteArrayOutputStream();
4039
new BuildTargetNote().encodeTo(targetNote);
4140
ByteArrayOutputStream outcomeNote = new ByteArrayOutputStream();
42-
return new byte[][]{targetNote.toByteArray(), outcomeNote.toByteArray()};
41+
return new byte[][] { targetNote.toByteArray(), outcomeNote.toByteArray() };
4342
} catch (IOException e) {
4443
throw new RuntimeException(e);
4544
}
@@ -71,7 +70,7 @@ private static class ConsoleLogFilterImpl extends ConsoleLogFilter implements Se
7170
private static final long serialVersionUID = 1;
7271
private byte[][] buildNotes = createBuildNotes();
7372

74-
//Taking care of old MATLAB build actions.
73+
// Taking care of old MATLAB build actions.
7574
private Object readResolve() {
7675
if (buildNotes == null) {
7776
buildNotes = createBuildNotes();

src/main/java/com/mathworks/ci/BuildTargetNote.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
/**
44
* Copyright 2024 The MathWorks, Inc.
5-
*
65
*/
76

87
import com.google.common.annotations.VisibleForTesting;
@@ -14,7 +13,6 @@
1413
import hudson.console.ConsoleNote;
1514
import java.util.regex.Pattern;
1615

17-
1816
public class BuildTargetNote extends ConsoleNote {
1917
@VisibleForTesting
2018
@SuppressFBWarnings(value = "MS_SHOULD_BE_FINAL", justification = "Visible for testing")
@@ -26,10 +24,10 @@ public BuildTargetNote() {
2624
@Override
2725
public ConsoleAnnotator annotate(Object context, MarkupText text, int charPos) {
2826
MarkupText.SubText t = text.findToken(Pattern.compile("MATLAB-Build-"));
29-
String taskName = text.subText(13, text.length()-2).getText();
30-
taskName = taskName.replace("]","").trim();
27+
String taskName = text.subText(13, text.length() - 2).getText();
28+
taskName = taskName.replace("]", "").trim();
3129
if (t != null)
32-
t.addMarkup(0, t.length()-1, "<a id= matlab" + taskName + " name=matlab" + taskName + ">", "</a>");
30+
t.addMarkup(0, t.length() - 1, "<a id= matlab" + taskName + " name=matlab" + taskName + ">", "</a>");
3331
return null;
3432
}
3533

src/main/java/com/mathworks/ci/FormValidationUtil.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
package com.mathworks.ci;
22

33
/**
4-
* Copyright 2019-2020 The MathWorks, Inc.
4+
* Copyright 2019-2024 The MathWorks, Inc.
55
*
66
* This is Utility class which provides commonly used methods for form validations across builders
7-
*
87
*/
98

109
import java.util.List;

src/main/java/com/mathworks/ci/ListenerLogDecorator.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package com.mathworks.ci;
22

3-
/*
4-
* Copyright 2018 The MathWorks, Inc.
5-
*/
3+
/**
4+
* Copyright 2018-2024 The MathWorks, Inc.
5+
*/
66

77
import java.io.IOException;
88
import java.io.OutputStream;

src/main/java/com/mathworks/ci/MatlabBuildWrapperContent.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
package com.mathworks.ci;
22

33
/**
4-
* Copyright 2020 The MathWorks, Inc.
4+
* Copyright 2020-2024 The MathWorks, Inc.
55
*
66
* Class to parse Stapler request for Use MATLAB Version build wrapper.
7-
*
87
*/
98

109
import org.kohsuke.stapler.DataBoundConstructor;
@@ -15,7 +14,7 @@ public class MatlabBuildWrapperContent {
1514
private final String matlabRootFolder;
1615

1716
@DataBoundConstructor
18-
public MatlabBuildWrapperContent(String matlabInstallationName, String matlabRootFolder){
17+
public MatlabBuildWrapperContent(String matlabInstallationName, String matlabRootFolder) {
1918
this.matlabInstallationName = matlabInstallationName;
2019
this.matlabRootFolder = matlabRootFolder;
2120
}
Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.mathworks.ci;
22

33
/*
4-
* Copyright 2019-2020 The MathWorks, Inc.
4+
* Copyright 2019-2024 The MathWorks, Inc.
55
*/
66

77
public class MatlabBuilderConstants {
@@ -11,43 +11,44 @@ public class MatlabBuilderConstants {
1111
public static final double BASE_MATLAB_VERSION_COBERTURA_SUPPORT = 9.3;
1212
public static final double BASE_MATLAB_VERSION_MODELCOVERAGE_SUPPORT = 9.5;
1313
public static final double BASE_MATLAB_VERSION_EXPORTSTMRESULTS_SUPPORT = 9.6;
14-
14+
1515
public static final String MATLAB_RUNNER_TARGET_FILE = "Builder.matlab.runner.target.file.name";
1616
public static final String MATLAB_TESTS_RUNNER_TARGET_FILE = "runMatlabTests.m";
1717
public static final String MATLAB_RUNNER_RESOURCE = "com/mathworks/ci/MatlabBuilder/runMatlabTests.m";
1818
public static final String AUTOMATIC_OPTION = "RunTestsAutomaticallyOption";
19-
20-
// Input parameter names (Passed to runMatlabTests.m as name-value pair arguments)
19+
20+
// Input parameter names (Passed to runMatlabTests.m as name-value pair
21+
// arguments)
2122
public static final String PDF_REPORT = "'PDFReport'";
2223
public static final String TAP_RESULTS = "'TAPResults'";
2324
public static final String JUNIT_RESULTS = "'JUnitResults'";
2425
public static final String STM_RESULTS = "'SimulinkTestResults'";
2526
public static final String COBERTURA_CODE_COVERAGE = "'CoberturaCodeCoverage'";
2627
public static final String COBERTURA_MODEL_COVERAGE = "'CoberturaModelCoverage'";
27-
28-
//Matlab Script generator package
28+
29+
// Matlab Script generator package
2930
public static final String MATLAB_SCRIPT_GENERATOR = "matlab-script-generator.zip";
30-
31-
//Test runner file prefix
31+
32+
// Test runner file prefix
3233
public static final String MATLAB_TEST_RUNNER_FILE_PREFIX = "runner_";
33-
34-
//Temporary MATLAB folder name in workspace
34+
35+
// Temporary MATLAB folder name in workspace
3536
public static final String TEMP_MATLAB_FOLDER_NAME = ".matlab";
3637

3738
// MATLAB default function/plugin paths
3839
public static final String DEFAULT_PLUGIN = "+ciplugins/+jenkins/getDefaultPlugins.m";
3940
public static final String BUILD_REPORT_PLUGIN = "+ciplugins/+jenkins/BuildReportPlugin.m";
4041
public static final String TASK_RUN_PROGRESS_PLUGIN = "+ciplugins/+jenkins/TaskRunProgressPlugin.m";
4142
public static final String BUILD_ARTIFACT = "buildArtifact";
42-
43+
4344
public static final String NEW_LINE = System.getProperty("line.separator");
4445

45-
//MATLAB Runner Script
46+
// MATLAB Runner Script
4647
public static final String TEST_RUNNER_SCRIPT = String.join(NEW_LINE,
47-
"addpath('${TEMP_FOLDER}');",
48-
"testScript = genscript(${PARAMS});",
49-
"disp('Running MATLAB script with content:');",
50-
"disp(testScript.Contents);",
51-
"fprintf('___________________________________\\n\\n');",
52-
"run(testScript);");
48+
"addpath('${TEMP_FOLDER}');",
49+
"testScript = genscript(${PARAMS});",
50+
"disp('Running MATLAB script with content:');",
51+
"disp(testScript.Contents);",
52+
"fprintf('___________________________________\\n\\n');",
53+
"run(testScript);");
5354
}

src/main/java/com/mathworks/ci/MatlabExecutionException.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
package com.mathworks.ci;
22

33
/**
4-
* Copyright 2021 The MathWorks, Inc.
5-
*
4+
* Copyright 2021-2024 The MathWorks, Inc.
65
*/
76

87
import java.lang.Exception;

src/main/java/com/mathworks/ci/MatlabInstallation.java

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
package com.mathworks.ci;
22

33
/**
4-
* Copyright 2020 The MathWorks, Inc.
4+
* Copyright 2020-2024 The MathWorks, Inc.
55
*
66
* Describable class for adding MATLAB installations in Jenkins Global Tool configuration.
7-
*
87
*/
98

109
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
@@ -36,7 +35,8 @@
3635
import org.kohsuke.stapler.DataBoundConstructor;
3736
import org.kohsuke.stapler.StaplerRequest;
3837

39-
public class MatlabInstallation extends ToolInstallation implements EnvironmentSpecific<MatlabInstallation>, NodeSpecific<MatlabInstallation> {
38+
public class MatlabInstallation extends ToolInstallation
39+
implements EnvironmentSpecific<MatlabInstallation>, NodeSpecific<MatlabInstallation> {
4040
private static final long serialVersionUID = 1L;
4141

4242
@DataBoundConstructor
@@ -45,14 +45,15 @@ public MatlabInstallation(String name, @CheckForNull String home, List<? extends
4545
}
4646

4747
/*
48-
* Constructor for Custom object
49-
* */
48+
* Constructor for Custom object
49+
*/
5050

51-
public MatlabInstallation(String name){
51+
public MatlabInstallation(String name) {
5252
super(name, null, null);
5353
}
5454

55-
@Override public MatlabInstallation forEnvironment(EnvVars envVars) {
55+
@Override
56+
public MatlabInstallation forEnvironment(EnvVars envVars) {
5657
return new MatlabInstallation(getName(), envVars.expand(getHome()), getProperties().toList());
5758
}
5859

@@ -61,26 +62,25 @@ public MatlabInstallation forNode(@Nonnull Node node, TaskListener log) throws I
6162
return new MatlabInstallation(getName(), translateFor(node, log), getProperties().toList());
6263
}
6364

64-
@SuppressFBWarnings(value = {"NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE"},
65-
justification =
66-
"NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE: Its false positive scenario for sport bug which is fixed in later versions "
67-
+ "https://github.com/spotbugs/spotbugs/issues/1843")
65+
@SuppressFBWarnings(value = {
66+
"NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE" }, justification = "NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE: Its false positive scenario for sport bug which is fixed in later versions "
67+
+ "https://github.com/spotbugs/spotbugs/issues/1843")
6868
@Override
6969
public void buildEnvVars(EnvVars env) {
7070
String pathToExecutable = getHome() + "/bin";
7171
env.put("PATH+matlabroot", pathToExecutable);
7272
Jenkins jenkinsInstance = Jenkins.getInstanceOrNull();
73-
if(jenkinsInstance != null){
74-
if(jenkinsInstance.getChannel() != null){
75-
FilePath batchExecutablePath = new FilePath(jenkinsInstance.getChannel (), getHome());
76-
if( batchExecutablePath.getParent() != null ){
77-
env.put ("PATH+matlab_batch", batchExecutablePath.getParent().getRemote());
73+
if (jenkinsInstance != null) {
74+
if (jenkinsInstance.getChannel() != null) {
75+
FilePath batchExecutablePath = new FilePath(jenkinsInstance.getChannel(), getHome());
76+
if (batchExecutablePath.getParent() != null) {
77+
env.put("PATH+matlab_batch", batchExecutablePath.getParent().getRemote());
7878
}
7979
}
8080
}
8181
}
8282

83-
public static MatlabInstallation[] getAll () {
83+
public static MatlabInstallation[] getAll() {
8484
return Jenkins.get().getDescriptorByType(DescriptorImpl.class).getInstallations();
8585
}
8686

@@ -97,7 +97,8 @@ public static MatlabInstallation getInstallation(String name) {
9797
return null;
9898
}
9999

100-
@Extension @Symbol("matlab")
100+
@Extension
101+
@Symbol("matlab")
101102
public static class DescriptorImpl extends ToolDescriptor<MatlabInstallation> {
102103
@CopyOnWrite
103104
private volatile MatlabInstallation[] installations = new MatlabInstallation[0];

0 commit comments

Comments
 (0)