Skip to content

Commit 2058723

Browse files
committed
Fix CheckStyle/PMD
1 parent 00636a9 commit 2058723

File tree

4 files changed

+43
-43
lines changed

4 files changed

+43
-43
lines changed

src/main/java/software/xdev/saveactions/model/Storage.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package software.xdev.saveactions.model;
22

33
import java.util.ArrayList;
4+
import java.util.EnumSet;
45
import java.util.HashSet;
56
import java.util.List;
67
import java.util.Objects;
@@ -30,7 +31,7 @@ public final class Storage implements PersistentStateComponent<Storage>
3031
public Storage()
3132
{
3233
this.firstLaunch = true;
33-
this.actions = new HashSet<>();
34+
this.actions = EnumSet.noneOf(Action.class);
3435
this.exclusions = new HashSet<>();
3536
this.inclusions = new HashSet<>();
3637
this.configurationPath = null;
@@ -41,7 +42,7 @@ public Storage()
4142
public Storage(final Storage storage)
4243
{
4344
this.firstLaunch = storage.firstLaunch;
44-
this.actions = new HashSet<>(storage.actions);
45+
this.actions = EnumSet.copyOf(storage.actions);
4546
this.exclusions = new HashSet<>(storage.exclusions);
4647
this.inclusions = new HashSet<>(storage.inclusions);
4748
this.configurationPath = storage.configurationPath;

src/main/java/software/xdev/saveactions/processors/java/inspection/CustomLocalCanBeFinal.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,6 @@ private boolean isNotLombokVal(final PsiElement element)
4848
{
4949
return Arrays
5050
.stream(element.getParent().getChildren())
51-
.noneMatch(child -> child instanceof PsiTypeElement && child.getText().equals("val"));
51+
.noneMatch(child -> child instanceof PsiTypeElement && "val".equals(child.getText()));
5252
}
5353
}

src/test/java/software/xdev/saveactions/core/action/BatchActionConstants.java

+2-3
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,10 @@
99

1010
public interface BatchActionConstants
1111
{
12-
13-
Consumer<CodeInsightTestFixture> SAVE_ACTION_BATCH_MANAGER = (fixture) ->
12+
Consumer<CodeInsightTestFixture> SAVE_ACTION_BATCH_MANAGER = fixture ->
1413
WriteCommandAction.writeCommandAction(fixture.getProject()).run(() -> runFixure(fixture));
1514

16-
static void runFixure(CodeInsightTestFixture fixture)
15+
static void runFixure(final CodeInsightTestFixture fixture)
1716
{
1817
// set modification timestamp ++
1918
fixture.getFile().clearCaches();

src/test/java/software/xdev/saveactions/model/java/EpfStorageTest.java

+37-37
Original file line numberDiff line numberDiff line change
@@ -36,61 +36,61 @@ class EpfStorageTest
3636
@BeforeEach
3737
void before()
3838
{
39-
storage = new Storage();
39+
this.storage = new Storage();
4040

41-
storage.setActions(new HashSet<>());
42-
storage.setInclusions(new HashSet<>());
43-
storage.setExclusions(new HashSet<>());
41+
this.storage.setActions(EnumSet.noneOf(Action.class));
42+
this.storage.setInclusions(new HashSet<>());
43+
this.storage.setExclusions(new HashSet<>());
4444

45-
storage.getActions().add(activate);
46-
storage.getActions().add(reformat);
47-
storage.getActions().add(reformatChangedCode);
48-
storage.getActions().add(fieldCanBeFinal);
49-
storage.getActions().add(missingOverrideAnnotation);
50-
storage.getActions().add(unnecessarySemicolon);
45+
this.storage.getActions().add(activate);
46+
this.storage.getActions().add(reformat);
47+
this.storage.getActions().add(reformatChangedCode);
48+
this.storage.getActions().add(fieldCanBeFinal);
49+
this.storage.getActions().add(missingOverrideAnnotation);
50+
this.storage.getActions().add(unnecessarySemicolon);
5151

52-
storage.getInclusions().add("inclusion1");
53-
storage.getInclusions().add("inclusion2");
52+
this.storage.getInclusions().add("inclusion1");
53+
this.storage.getInclusions().add("inclusion2");
5454

55-
storage.getExclusions().add("exclusion1");
56-
storage.getExclusions().add("exclusion2");
55+
this.storage.getExclusions().add("exclusion1");
56+
this.storage.getExclusions().add("exclusion2");
5757
}
5858

5959
@Test
6060
void should_storage_with_bad_configuration_path_returns_default_storage()
6161
{
6262
Storage epfStorage;
6363

64-
epfStorage = EpfStorage.INSTANCE.getStorageOrDefault(storage.getConfigurationPath(), storage);
65-
assertThat(storage).isSameAs(epfStorage);
64+
epfStorage = EpfStorage.INSTANCE.getStorageOrDefault(this.storage.getConfigurationPath(), this.storage);
65+
assertThat(this.storage).isSameAs(epfStorage);
6666

67-
storage.setConfigurationPath("bad path");
68-
epfStorage = EpfStorage.INSTANCE.getStorageOrDefault(storage.getConfigurationPath(), storage);
69-
assertThat(storage).isSameAs(epfStorage);
67+
this.storage.setConfigurationPath("bad path");
68+
epfStorage = EpfStorage.INSTANCE.getStorageOrDefault(this.storage.getConfigurationPath(), this.storage);
69+
assertThat(this.storage).isSameAs(epfStorage);
7070
}
7171

7272
@Test
7373
void should_default_storage_values_are_copied_to_epf_storage_if_empty_file()
7474
{
75-
Storage epfStorage = EpfStorage.INSTANCE.getStorageOrDefault(EXAMPLE_EPF_0.toString(), storage);
76-
assertThat(epfStorage).isNotSameAs(storage);
75+
final Storage epfStorage = EpfStorage.INSTANCE.getStorageOrDefault(EXAMPLE_EPF_0.toString(), this.storage);
76+
assertThat(epfStorage).isNotSameAs(this.storage);
7777

78-
assertThat(epfStorage.getActions()).isNotSameAs(storage.getActions());
79-
assertThat(epfStorage.getInclusions()).isNotSameAs(storage.getInclusions());
80-
assertThat(epfStorage.getExclusions()).isNotSameAs(storage.getExclusions());
78+
assertThat(epfStorage.getActions()).isNotSameAs(this.storage.getActions());
79+
assertThat(epfStorage.getInclusions()).isNotSameAs(this.storage.getInclusions());
80+
assertThat(epfStorage.getExclusions()).isNotSameAs(this.storage.getExclusions());
8181

82-
assertThat(epfStorage.getActions()).isEqualTo(storage.getActions());
83-
assertThat(epfStorage.getInclusions()).isEqualTo(storage.getInclusions());
84-
assertThat(epfStorage.getExclusions()).isEqualTo(storage.getExclusions());
82+
assertThat(epfStorage.getActions()).isEqualTo(this.storage.getActions());
83+
assertThat(epfStorage.getInclusions()).isEqualTo(this.storage.getInclusions());
84+
assertThat(epfStorage.getExclusions()).isEqualTo(this.storage.getExclusions());
8585
}
8686

8787
@Test
8888
void should_storage_values_are_correct_for_file_format_1()
8989
{
90-
Storage epfStorage = EpfStorage.INSTANCE.getStorageOrDefault(EXAMPLE_EPF_1.toString(), storage);
91-
assertThat(epfStorage).isNotSameAs(storage);
90+
final Storage epfStorage = EpfStorage.INSTANCE.getStorageOrDefault(EXAMPLE_EPF_1.toString(), this.storage);
91+
assertThat(epfStorage).isNotSameAs(this.storage);
9292

93-
EnumSet<Action> expected = EnumSet.of(
93+
final EnumSet<Action> expected = EnumSet.of(
9494
// from default store (not in java)
9595
activate,
9696
// in both store
@@ -116,17 +116,17 @@ void should_storage_values_are_correct_for_file_format_1()
116116
);
117117

118118
assertThat(epfStorage.getActions()).isEqualTo(expected);
119-
assertThat(epfStorage.getInclusions()).isEqualTo(storage.getInclusions());
120-
assertThat(epfStorage.getExclusions()).isEqualTo(storage.getExclusions());
119+
assertThat(epfStorage.getInclusions()).isEqualTo(this.storage.getInclusions());
120+
assertThat(epfStorage.getExclusions()).isEqualTo(this.storage.getExclusions());
121121
}
122122

123123
@Test
124124
void should_storage_values_are_correct_for_file_format_2()
125125
{
126-
Storage epfStorage = EpfStorage.INSTANCE.getStorageOrDefault(EXAMPLE_EPF_2.toString(), storage);
127-
assertThat(epfStorage).isNotSameAs(storage);
126+
final Storage epfStorage = EpfStorage.INSTANCE.getStorageOrDefault(EXAMPLE_EPF_2.toString(), this.storage);
127+
assertThat(epfStorage).isNotSameAs(this.storage);
128128

129-
EnumSet<Action> expected = EnumSet.of(
129+
final EnumSet<Action> expected = EnumSet.of(
130130
missingOverrideAnnotation,
131131
unnecessarySemicolon,
132132
rearrange,
@@ -141,7 +141,7 @@ void should_storage_values_are_correct_for_file_format_2()
141141
);
142142

143143
assertThat(epfStorage.getActions()).isEqualTo(expected);
144-
assertThat(epfStorage.getInclusions()).isEqualTo(storage.getInclusions());
145-
assertThat(epfStorage.getExclusions()).isEqualTo(storage.getExclusions());
144+
assertThat(epfStorage.getInclusions()).isEqualTo(this.storage.getInclusions());
145+
assertThat(epfStorage.getExclusions()).isEqualTo(this.storage.getExclusions());
146146
}
147147
}

0 commit comments

Comments
 (0)