Skip to content

Commit 6080247

Browse files
more lint fixes
1 parent 6f001ef commit 6080247

File tree

3 files changed

+34
-29
lines changed

3 files changed

+34
-29
lines changed

gradle-tasks/staticChecks.gradle

+6-6
Original file line numberDiff line numberDiff line change
@@ -23,34 +23,34 @@ pmd {
2323
ruleSets = []
2424
}
2525

26-
tasks.withType(Checkstyle) {
26+
tasks.withType(Checkstyle).configureEach {
2727
// Specify all files that should be checked
2828
classpath = files()
2929
source "${project.rootDir}"
3030
}
3131

3232
// Execute Checkstyle on all files
33-
task checkstyle(type: Checkstyle) {
33+
tasks.register('checkstyle', Checkstyle) {
3434
}
3535

3636
// Execute Checkstyle on all modified files
37-
task checkstyleCI(type: Checkstyle) {
37+
tasks.register('checkstyleCI', Checkstyle) {
3838
def changedFiles = getChangedFiles()
3939
include changedFiles
4040
}
4141

42-
tasks.withType(Pmd) {
42+
tasks.withType(Pmd).configureEach {
4343
// Specify all files that should be checked
4444
classpath = files()
4545
source "${project.rootDir}"
4646
}
4747

4848
// Execute Checkstyle on all files
49-
task pmd(type: Pmd) {
49+
tasks.register('pmd', Pmd) {
5050
}
5151

5252
// Execute Checkstyle on all modified files
53-
task pmdCI(type: Pmd) {
53+
tasks.register('pmdCI', Pmd) {
5454
def changedFiles = getChangedFiles()
5555
include changedFiles
5656
}

src/com/magento/idea/magento2plugin/magento/packages/ComposerPackageModelImpl.java

+15-10
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,14 @@
88
import org.apache.commons.lang3.StringUtils;
99
import org.jetbrains.annotations.NotNull;
1010
import org.jetbrains.annotations.Nullable;
11+
1112
import java.util.ArrayList;
1213
import java.util.HashMap;
1314
import java.util.List;
1415
import java.util.Map;
1516

1617
public class ComposerPackageModelImpl implements ComposerPackageModel {
17-
private JsonObject sourceComposerJson;
18+
private final JsonObject sourceComposerJson;
1819

1920
public static final String NAME = "name";
2021
public static final String TYPE = "type";
@@ -67,12 +68,12 @@ public String[] getAutoloadFiles() {
6768
JsonArray jsonArray = getPropertyValueOfType(FILES, JsonArray.class);
6869
if (jsonArray != null) {
6970
List<String> files = new ArrayList<>();
70-
for(JsonValue value: jsonArray.getValueList()) {
71+
for (JsonValue value : jsonArray.getValueList()) {
7172
if (value instanceof JsonStringLiteral) {
7273
files.add(StringUtils.strip(value.getText(), "\""));
7374
}
7475
}
75-
return files.size() > 0 ? files.toArray(new String[files.size()]) : null;
76+
return !files.isEmpty() ? files.toArray(new String[files.size()]) : null;
7677
}
7778
}
7879

@@ -86,30 +87,31 @@ public Map<String, String> getAutoloadPsr4() {
8687
if (autoloadObject != null) {
8788
JsonObject jsonObject = getPropertyValueOfType(PSR4, JsonObject.class);
8889
if (jsonObject != null) {
89-
Map <String, String> map = new HashMap<String, String>();
90-
for (JsonProperty property: jsonObject.getPropertyList()) {
90+
Map<String, String> map = new HashMap<String, String>();
91+
for (JsonProperty property : jsonObject.getPropertyList()) {
9192
JsonValue value = property.getValue();
9293

93-
if (value != null && value instanceof JsonStringLiteral) {
94+
if (value instanceof JsonStringLiteral) {
9495
map.put(property.getName(), StringUtils.strip(value.getText(), "\""));
9596
}
9697
}
9798

98-
return map.size() > 0 ? map : null;
99+
return !map.isEmpty() ? map : null;
99100
}
100101
}
101102

102103
return null;
103104
}
104105

105106
@Nullable
106-
public <T extends JsonValue> T getPropertyValueOfType(String propertyName, @NotNull Class<T> aClass) {
107+
public <T extends JsonValue> T getPropertyValueOfType(String propertyName,
108+
@NotNull Class<T> aClass) {
107109
JsonProperty property = sourceComposerJson.findProperty(propertyName);
108110
if (property == null) {
109111
return null;
110112
}
111113
JsonValue value = property.getValue();
112-
if (value != null && aClass.isInstance(value)) {
114+
if (aClass.isInstance(value)) {
113115
return aClass.cast(value);
114116
}
115117

@@ -118,7 +120,10 @@ public <T extends JsonValue> T getPropertyValueOfType(String propertyName, @NotN
118120

119121
@Nullable
120122
private String getStringPropertyValue(String propertyName) {
121-
JsonStringLiteral stringLiteral = getPropertyValueOfType(propertyName, JsonStringLiteral.class);
123+
JsonStringLiteral stringLiteral = getPropertyValueOfType(
124+
propertyName,
125+
JsonStringLiteral.class
126+
);
122127

123128
if (stringLiteral != null) {
124129
return StringUtils.strip(stringLiteral.getText(), "\"");

src/com/magento/idea/magento2plugin/project/startup/CheckIfMagentoPathIsValidActivity.java

+13-13
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,6 @@
1818

1919
public class CheckIfMagentoPathIsValidActivity implements StartupActivity, ProjectActivity {
2020

21-
public void registerSettings(final @NotNull Project project) {
22-
final Settings settings = Settings.getInstance(project);
23-
final String path = settings.magentoPath;
24-
if (settings.pluginEnabled && (path == null || path.isEmpty())) {
25-
if (MagentoBasePathUtil.isMagentoFolderValid(project.getBasePath())) {
26-
settings.setMagentoPath(project.getBasePath());
27-
return;
28-
}
29-
settings.pluginEnabled = false;
30-
ConfigurationManager.suggestToConfigureMagentoPath(project);
31-
}
32-
}
33-
3421
@Override
3522
public void runActivity(final @NotNull Project project) {
3623
registerSettings(project);
@@ -43,4 +30,17 @@ public Object execute(@NotNull Project project,
4330
registerSettings(project);
4431
return null;
4532
}
33+
34+
private void registerSettings(final @NotNull Project project) {
35+
final Settings settings = Settings.getInstance(project);
36+
final String path = settings.magentoPath;
37+
if (settings.pluginEnabled && (path == null || path.isEmpty())) {
38+
if (MagentoBasePathUtil.isMagentoFolderValid(project.getBasePath())) {
39+
settings.setMagentoPath(project.getBasePath());
40+
return;
41+
}
42+
settings.pluginEnabled = false;
43+
ConfigurationManager.suggestToConfigureMagentoPath(project);
44+
}
45+
}
4646
}

0 commit comments

Comments
 (0)