Skip to content

Commit 7eeb20f

Browse files
Static check fixes
1 parent 6a2b461 commit 7eeb20f

13 files changed

+120
-102
lines changed

src/com/magento/idea/magento2uct/execution/DownloadUctCommand.java

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,11 @@ public DownloadUctCommand(final @NotNull Project project) {
4242
/**
4343
* Start UCT downloading process.
4444
*/
45-
public void execute() {
45+
public void execute() throws ExecutionException {
4646
final ConsoleView consoleView = createConsole();
47-
try {
48-
final OSProcessHandler processHandler = createProcessHandler();
49-
consoleView.attachToProcess(processHandler);
50-
processHandler.startNotify();
51-
} catch (ExecutionException exception) {
52-
//NOPMD
53-
}
47+
final OSProcessHandler processHandler = createProcessHandler();
48+
consoleView.attachToProcess(processHandler);
49+
processHandler.startNotify();
5450
}
5551

5652
/**
@@ -87,15 +83,15 @@ private OSProcessHandler createProcessHandler() throws ExecutionException {
8783
*
8884
* @return GeneralCommandLine
8985
*/
90-
private GeneralCommandLine createGeneralCommandLine(boolean withPty) {
86+
private GeneralCommandLine createGeneralCommandLine(final boolean withPty) {
9187
GeneralCommandLine commandLine;
9288

9389
if (withPty) {
94-
if (!SystemInfo.isWindows) {
95-
commandLine = new PtyCommandLine().withInitialColumns(2500);
96-
} else {
90+
if (SystemInfo.isWindows) {
9791
commandLine = new GeneralCommandLine();
9892
commandLine.getEnvironment().putIfAbsent("TERM", "xterm");
93+
} else {
94+
commandLine = new PtyCommandLine().withInitialColumns(2500);
9995
}
10096
} else {
10197
commandLine = new GeneralCommandLine();

src/com/magento/idea/magento2uct/execution/configurations/UctConfigurationFactory.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ protected UctConfigurationFactory(final @NotNull ConfigurationType type) {
2626

2727
@Override
2828
public @NotNull String getId() {
29-
return UctRunConfigurationType.ID;
29+
return UctRunConfigurationType.RUN_CONFIGURATION_TYPE_ID;
3030
}
3131

3232
@Override

src/com/magento/idea/magento2uct/execution/configurations/UctRunConfiguration.java

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
import com.intellij.execution.configurations.LocatableConfigurationBase;
1515
import com.intellij.execution.configurations.RunConfiguration;
1616
import com.intellij.execution.configurations.RunProfileState;
17-
import com.intellij.execution.configurations.RuntimeConfigurationException;
1817
import com.intellij.execution.process.OSProcessHandler;
1918
import com.intellij.execution.process.ProcessHandler;
2019
import com.intellij.execution.process.ProcessHandlerFactory;
@@ -36,6 +35,12 @@
3635
import org.jetbrains.annotations.NotNull;
3736
import org.jetbrains.annotations.Nullable;
3837

38+
@SuppressWarnings({
39+
"PMD.NPathComplexity",
40+
"PMD.CyclomaticComplexity",
41+
"PMD.ExcessiveImports",
42+
"PMD.CognitiveComplexity"
43+
})
3944
public class UctRunConfiguration extends LocatableConfigurationBase<UctRunConfigurationOptions> {
4045

4146
/**
@@ -154,7 +159,7 @@ public int getMinIssueLevel() {
154159
* @param hasIgnoreCurrentVersionIssues boolean
155160
*/
156161
public void setHasIgnoreCurrentVersionIssues(final boolean hasIgnoreCurrentVersionIssues) {
157-
getOptions().setHasIgnoreCurrentVersionIssues(hasIgnoreCurrentVersionIssues);
162+
getOptions().setIgnoreCurrentVersionIssues(hasIgnoreCurrentVersionIssues);
158163
}
159164

160165
/**
@@ -172,7 +177,7 @@ public boolean hasIgnoreCurrentVersionIssues() {
172177
* @param isNewlyCreated boolean
173178
*/
174179
public void setIsNewlyCreated(final boolean isNewlyCreated) {
175-
getOptions().setIsNewlyCreated(isNewlyCreated);
180+
getOptions().setNewlyCreated(isNewlyCreated);
176181
}
177182

178183
/**
@@ -189,11 +194,6 @@ public boolean isNewlyCreated() {
189194
return new UctSettingsEditor(getProject());
190195
}
191196

192-
@Override
193-
public void checkConfiguration() throws RuntimeConfigurationException {
194-
super.checkConfiguration();
195-
}
196-
197197
@Override
198198
public @Nullable @NlsActions.ActionText String suggestedName() {
199199
return this.getName().isEmpty() ? RunManager.getInstance(getProject()).suggestUniqueName(
@@ -211,9 +211,7 @@ public void checkConfiguration() throws RuntimeConfigurationException {
211211

212212
@Override
213213
protected @NotNull ProcessHandler startProcess() throws ExecutionException {
214-
final UctSettingsService settingsService =
215-
UctSettingsService.getInstance(getProject());
216-
PhpInterpreter interpreter = PhpProjectConfigurationFacade
214+
final PhpInterpreter interpreter = PhpProjectConfigurationFacade
217215
.getInstance(getProject())
218216
.getInterpreter();
219217

@@ -224,6 +222,8 @@ public void checkConfiguration() throws RuntimeConfigurationException {
224222
}
225223

226224
final boolean isValidPath = UctExecutableValidatorUtil.validate(getScriptName());
225+
final UctSettingsService settingsService =
226+
UctSettingsService.getInstance(getProject());
227227

228228
if (getScriptName().isEmpty()) {
229229
throw new ExecutionException("The UCT executable path is not specified");
@@ -260,18 +260,17 @@ public void checkConfiguration() throws RuntimeConfigurationException {
260260
final GeneralCommandLine commandLine =
261261
commandSettingsBuilder.createGeneralCommandLine();
262262

263-
final IssueSeverityLevel severityLevel =
264-
IssueSeverityLevel.getByLevel(getMinIssueLevel());
265-
final IssueSeverityLevel defaultSeverityLevel =
266-
IssueSeverityLevel.getDefaultIssueSeverityLevel();
267-
268263
if (!getModulePath().isEmpty()) {
269264
if (UctModulePathValidatorUtil.validate(getModulePath())) {
270265
commandLine.addParameter("--module-path=".concat(getModulePath()));
271266
} else {
272267
throw new ExecutionException("The path to analyse is not valid");
273268
}
274269
}
270+
final IssueSeverityLevel severityLevel =
271+
IssueSeverityLevel.getByLevel(getMinIssueLevel());
272+
final IssueSeverityLevel defaultSeverityLevel =
273+
IssueSeverityLevel.getDefaultIssueSeverityLevel();
275274

276275
if (!severityLevel.equals(defaultSeverityLevel)) {
277276
commandLine

src/com/magento/idea/magento2uct/execution/configurations/UctRunConfigurationOptions.java

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ public class UctRunConfigurationOptions extends LocatableRunConfigurationOptions
2020
.provideDelegate(this, "comingVersion");
2121
private final StoredProperty<Integer> minIssueLevel = property(3)
2222
.provideDelegate(this, "minIssueLevel");
23-
private final StoredProperty<Boolean> hasIgnoreCurrentVersionIssues = property(false)
23+
private final StoredProperty<Boolean> ignoreCurrentVersionIssues = property(false)
2424
.provideDelegate(this, "hasIgnoreCurrentVersionIssues");
25-
private final StoredProperty<Boolean> isNewlyCreated = property(true)
25+
private final StoredProperty<Boolean> newlyCreated = property(true)
2626
.provideDelegate(this, "isNewlyCreated");
2727

2828
/**
@@ -40,7 +40,7 @@ public void setScriptName(final String scriptName) {
4040
* @return String
4141
*/
4242
public String getScriptName() {
43-
return myScriptName.getValue(this) != null ? myScriptName.getValue(this) : "";
43+
return myScriptName.getValue(this) == null ? "" : myScriptName.getValue(this);
4444
}
4545

4646
/**
@@ -58,7 +58,7 @@ public void setProjectRoot(final String projectRoot) {
5858
* @return String
5959
*/
6060
public String getProjectRoot() {
61-
return projectRoot.getValue(this) != null ? projectRoot.getValue(this) : "";
61+
return projectRoot.getValue(this) == null ? "" : projectRoot.getValue(this);
6262
}
6363

6464
/**
@@ -76,7 +76,7 @@ public void setModulePath(final String modulePath) {
7676
* @return String
7777
*/
7878
public String getModulePath() {
79-
return modulePath.getValue(this) != null ? modulePath.getValue(this) : "";
79+
return modulePath.getValue(this) == null ? "" : modulePath.getValue(this);
8080
}
8181

8282
/**
@@ -94,7 +94,7 @@ public void setComingVersion(final String comingVersion) {
9494
* @return String
9595
*/
9696
public String getComingVersion() {
97-
return comingVersion.getValue(this) != null ? comingVersion.getValue(this) : "";
97+
return comingVersion.getValue(this) == null ? "" : comingVersion.getValue(this);
9898
}
9999

100100
/**
@@ -118,10 +118,10 @@ public int getMinIssueLevel() {
118118
/**
119119
* Set ignoring for current version issues setting.
120120
*
121-
* @param hasIgnoreCurrentVersionIssues boolean
121+
* @param ignoreCurrentVersionIssues boolean
122122
*/
123-
public void setHasIgnoreCurrentVersionIssues(final boolean hasIgnoreCurrentVersionIssues) {
124-
this.hasIgnoreCurrentVersionIssues.setValue(this, hasIgnoreCurrentVersionIssues);
123+
public void setIgnoreCurrentVersionIssues(final boolean ignoreCurrentVersionIssues) {
124+
this.ignoreCurrentVersionIssues.setValue(this, ignoreCurrentVersionIssues);
125125
}
126126

127127
/**
@@ -130,16 +130,16 @@ public void setHasIgnoreCurrentVersionIssues(final boolean hasIgnoreCurrentVersi
130130
* @return boolean
131131
*/
132132
public boolean hasIgnoreCurrentVersionIssues() {
133-
return hasIgnoreCurrentVersionIssues.getValue(this);
133+
return ignoreCurrentVersionIssues.getValue(this);
134134
}
135135

136136
/**
137137
* Set is settings is newly created.
138138
*
139-
* @param isNewlyCreated boolean
139+
* @param newlyCreated boolean
140140
*/
141-
public void setIsNewlyCreated(final boolean isNewlyCreated) {
142-
this.isNewlyCreated.setValue(this, isNewlyCreated);
141+
public void setNewlyCreated(final boolean newlyCreated) {
142+
this.newlyCreated.setValue(this, newlyCreated);
143143
}
144144

145145
/**
@@ -148,6 +148,6 @@ public void setIsNewlyCreated(final boolean isNewlyCreated) {
148148
* @return boolean
149149
*/
150150
public boolean isNewlyCreated() {
151-
return isNewlyCreated.getValue(this);
151+
return newlyCreated.getValue(this);
152152
}
153153
}

src/com/magento/idea/magento2uct/execution/configurations/UctRunConfigurationType.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
public class UctRunConfigurationType implements ConfigurationType {
1515

16-
public static final String ID = "UctRunConfigurationType";
16+
public static final String RUN_CONFIGURATION_TYPE_ID = "UctRunConfigurationType";
1717
public static final String TITLE = "Upgrade Compatibility Tool";
1818
public static final String SHORT_TITLE = "UCT Run";
1919
private static final String DESCRIPTION = "Magento 2 Upgrade Compatibility Tool Configuration";
@@ -35,7 +35,7 @@ public Icon getIcon() {
3535

3636
@Override
3737
public @NotNull String getId() {
38-
return ID;
38+
return RUN_CONFIGURATION_TYPE_ID;
3939
}
4040

4141
@Override

src/com/magento/idea/magento2uct/execution/configurations/UctSettingsEditor.form

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@
8484
<text value="Minimum issue level to show in report. Default is [WARNING]."/>
8585
</properties>
8686
</component>
87-
<component id="18a6c" class="javax.swing.JRadioButton" binding="hasIgnoreCurrentVersionIssues">
87+
<component id="18a6c" class="javax.swing.JRadioButton" binding="ignoreCurrentVersionIssues">
8888
<constraints>
8989
<grid row="10" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
9090
</constraints>

0 commit comments

Comments
 (0)