Skip to content

Commit f515234

Browse files
author
Vitaliy Boyko
committed
Fixed PMD rules
1 parent 83822f4 commit f515234

File tree

3 files changed

+43
-21
lines changed

3 files changed

+43
-21
lines changed

gradle-tasks/pmd/ruleset.xml

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?xml version="1.0"?>
2+
3+
<ruleset name="Custom Rules"
4+
xmlns="http://pmd.sourceforge.net/ruleset/2.0.0"
5+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
6+
xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0 https://pmd.sourceforge.io/ruleset_2_0_0.xsd">
7+
8+
<description>
9+
Magento PhpStorm rules
10+
</description>
11+
<rule ref="category/java/bestpractices.xml" />
12+
<rule ref="category/java/codestyle.xml"/>
13+
<rule ref="category/java/design.xml">
14+
<exclude name="LawOfDemeter"/>
15+
</rule>
16+
<rule ref="category/java/documentation.xml">
17+
<exclude name="CommentRequired" />
18+
</rule>
19+
<rule ref="category/java/errorprone.xml">
20+
<exclude name="BeanMembersShouldSerialize"/>
21+
</rule>
22+
<rule ref="category/java/multithreading.xml"/>
23+
<rule ref="category/java/performance.xml"/>
24+
<rule ref="category/java/security.xml" />
25+
</ruleset>

gradle-tasks/staticChecks.gradle

+1-6
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,7 @@ pmd {
2121
consoleOutput = true
2222
rulePriority = 5
2323
ruleSets = [
24-
"category/java/codestyle.xml",
25-
"category/java/design.xml",
26-
"category/java/errorprone.xml",
27-
"category/java/bestpractices.xml",
28-
"category/java/performance.xml",
29-
"category/java/security.xml",
24+
"gradle-tasks/pmd/ruleset.xml"
3025
]
3126
}
3227

src/com/magento/idea/magento2plugin/actions/generation/dialog/CreateAnObserverDialog.java

+17-15
Original file line numberDiff line numberDiff line change
@@ -30,33 +30,35 @@
3030
import javax.swing.KeyStroke;
3131
import org.jetbrains.annotations.NotNull;
3232

33-
public class CreateAnObserverDialog extends AbstractDialog {
33+
public class CreateAnObserverDialog extends AbstractDialog {//NOPMD
3434
@NotNull
3535
private final Project project;
3636
@NotNull
3737
private final CreateAnObserverDialogValidator validator;
38-
private String targetEvent;
38+
private final String targetEvent;
3939
private JPanel contentPane;
4040
private JButton buttonOK;
4141
private JButton buttonCancel;
4242
private JTextField observerClassName;
43-
private JLabel observerClassNameLabel;
4443
private JTextField observerDirectory;
45-
private JLabel observerDirectoryName;
46-
private JLabel selectObserverModule;
4744
private FilteredComboBox observerModule;
4845
private JComboBox observerArea;
49-
private JLabel observerAreaLabel;
50-
private JLabel observerNameLabel;
5146
private JTextField observerName;
47+
private JLabel observerClassNameLabel;//NOPMD
48+
private JLabel observerDirectoryName;//NOPMD
49+
private JLabel selectObserverModule;//NOPMD
50+
private JLabel observerAreaLabel;//NOPMD
51+
private JLabel observerNameLabel;//NOPMD
5252

5353
/**
5454
* Constructor.
5555
*
5656
* @param project Project Scope
5757
* @param targetEvent Action Event
5858
*/
59-
public CreateAnObserverDialog(@NotNull Project project, String targetEvent) {
59+
public CreateAnObserverDialog(@NotNull final Project project, final String targetEvent) {
60+
super();
61+
6062
this.project = project;
6163
this.targetEvent = targetEvent;
6264
this.validator = CreateAnObserverDialogValidator.getInstance(this);
@@ -71,7 +73,7 @@ public CreateAnObserverDialog(@NotNull Project project, String targetEvent) {
7173

7274
setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
7375
addWindowListener(new WindowAdapter() {
74-
public void windowClosing(WindowEvent e) {
76+
public void windowClosing(final WindowEvent event) {
7577
onCancel();
7678
}
7779
});
@@ -89,8 +91,8 @@ public void windowClosing(WindowEvent e) {
8991
* @param project Project Scope
9092
* @param targetEvent Action Event
9193
*/
92-
public static void open(@NotNull Project project, String targetEvent) {
93-
CreateAnObserverDialog dialog = new CreateAnObserverDialog(project, targetEvent);
94+
public static void open(@NotNull final Project project, final String targetEvent) {
95+
final CreateAnObserverDialog dialog = new CreateAnObserverDialog(project, targetEvent);
9496
dialog.pack();
9597
dialog.centerDialog(dialog);
9698
dialog.setVisible(true);
@@ -100,7 +102,7 @@ public static void open(@NotNull Project project, String targetEvent) {
100102
* Setup observer area combobox.
101103
*/
102104
private void fillTargetAreaOptions() {
103-
for (Package.Areas area : Package.Areas.values()) {
105+
for (final Package.Areas area : Package.Areas.values()) {
104106
observerArea.addItem(area.toString());
105107
}
106108
}
@@ -152,14 +154,14 @@ public String getObserverModule() {
152154
return this.observerModule.getSelectedItem().toString();
153155
}
154156

155-
private void createUiComponents() {
156-
List<String> allModulesList = ModuleIndex.getInstance(project).getEditableModuleNames();
157+
private void createUiComponents() {//NOPMD
158+
final List<String> allModulesList = ModuleIndex.getInstance(project).getEditableModuleNames();
157159

158160
this.observerModule = new FilteredComboBox(allModulesList);
159161
}
160162

161163
private String getNamespace() {
162-
String targetModule = getObserverModule();
164+
final String targetModule = getObserverModule();
163165
String namespace = targetModule.replace(
164166
Package.VENDOR_MODULE_NAME_SEPARATOR,
165167
Package.FQN_SEPARATOR

0 commit comments

Comments
 (0)