Skip to content

Commit 1183194

Browse files
committed
Add di.xml tests, fix static tests, add resources and TestData folders to exclude pattern
1 parent ece7061 commit 1183194

File tree

22 files changed

+455
-154
lines changed

22 files changed

+455
-154
lines changed

gradle-tasks/pmd/ruleset.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
</rule>
1919
<rule ref="category/java/codestyle.xml">
2020
<exclude name="AtLeastOneConstructor" />
21+
<exclude name="LongVariable" />
2122
</rule>
2223
<rule ref="category/java/design.xml">
2324
<exclude name="LawOfDemeter"/>
@@ -28,6 +29,8 @@
2829
<rule ref="category/java/errorprone.xml">
2930
<exclude name="BeanMembersShouldSerialize"/>
3031
</rule>
32+
<exclude-pattern>.*/resources/.*</exclude-pattern>
33+
<exclude-pattern>.*/testData/.*</exclude-pattern>
3134
<rule ref="category/java/multithreading.xml"/>
3235
<rule ref="category/java/performance.xml"/>
3336
<rule ref="category/java/security.xml" />

resources/magento2/common.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,4 @@ common.cli.create.new.cli.command.title=Create a new Magento 2 CLI Command
3333
common.cli.generate.error=New CLI Command Generation Error
3434
common.cli.class.title=CLI Command Class
3535
common.validationErrorTitle=Validation Error
36+
common.defaultConsoleDirectory=Console

src/com/magento/idea/magento2plugin/actions/generation/NewCLICommandAction.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,10 @@
1717
import com.magento.idea.magento2plugin.actions.generation.dialog.NewCLICommandDialog;
1818
import org.jetbrains.annotations.NotNull;
1919

20+
@SuppressWarnings({"PMD.FieldNamingConventions", "PMD.OnlyOneReturn"})
2021
public class NewCLICommandAction extends AnAction {
21-
public static String ACTION_NAME = "Magento 2 CLI Command";//NOPMD
22-
public static String ACTION_DESCRIPTION = "Create a new Magento 2 CLI Command";//NOPMD
22+
public static String ACTION_NAME = "Magento 2 CLI Command";
23+
public static String ACTION_DESCRIPTION = "Create a new Magento 2 CLI Command";
2324

2425
public NewCLICommandAction() {
2526
super(ACTION_NAME, ACTION_DESCRIPTION, MagentoIcons.MODULE);
@@ -30,12 +31,12 @@ public void actionPerformed(@NotNull final AnActionEvent event) {
3031
final DataContext context = event.getDataContext();
3132
final IdeView view = LangDataKeys.IDE_VIEW.getData(context);
3233
if (view == null) {
33-
return;//NOPMD
34+
return;
3435
}
3536

3637
final Project project = CommonDataKeys.PROJECT.getData(context);
3738
if (project == null) {
38-
return;//NOPMD
39+
return;
3940
}
4041

4142
final PsiDirectory directory = view.getOrChooseDirectory();

src/com/magento/idea/magento2plugin/actions/generation/NewCronjobAction.java

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,39 +2,45 @@
22
* Copyright © Magento, Inc. All rights reserved.
33
* See COPYING.txt for license details.
44
*/
5+
56
package com.magento.idea.magento2plugin.actions.generation;
67

78
import com.intellij.ide.IdeView;
8-
import com.intellij.openapi.actionSystem.*;
9+
import com.intellij.openapi.actionSystem.AnAction;
10+
import com.intellij.openapi.actionSystem.AnActionEvent;
11+
import com.intellij.openapi.actionSystem.CommonDataKeys;
12+
import com.intellij.openapi.actionSystem.DataContext;
13+
import com.intellij.openapi.actionSystem.LangDataKeys;
914
import com.intellij.openapi.project.Project;
1015
import com.intellij.psi.PsiDirectory;
1116
import com.magento.idea.magento2plugin.MagentoIcons;
1217
import com.magento.idea.magento2plugin.actions.generation.dialog.NewCronjobDialog;
1318
import org.jetbrains.annotations.NotNull;
1419

20+
@SuppressWarnings({"PMD.FieldNamingConventions", "PMD.OnlyOneReturn"})
1521
public class NewCronjobAction extends AnAction {
1622
public static String ACTION_NAME = "Magento 2 Cronjob";
1723
public static String ACTION_DESCRIPTION = "Create a new Magento 2 cronjob";
1824

19-
NewCronjobAction() {
25+
public NewCronjobAction() {
2026
super(ACTION_NAME, ACTION_DESCRIPTION, MagentoIcons.MODULE);
2127
}
2228

2329
@Override
24-
public void actionPerformed(@NotNull AnActionEvent e) {
25-
DataContext dataContext = e.getDataContext();
26-
IdeView view = LangDataKeys.IDE_VIEW.getData(dataContext);
30+
public void actionPerformed(final @NotNull AnActionEvent event) {
31+
final DataContext dataContext = event.getDataContext();
32+
final IdeView view = LangDataKeys.IDE_VIEW.getData(dataContext);
2733

2834
if (view == null) {
2935
return;
3036
}
3137

32-
Project project = CommonDataKeys.PROJECT.getData(dataContext);
38+
final Project project = CommonDataKeys.PROJECT.getData(dataContext);
3339
if (project == null) {
3440
return;
3541
}
3642

37-
PsiDirectory directory = view.getOrChooseDirectory();
43+
final PsiDirectory directory = view.getOrChooseDirectory();
3844
if (directory == null) {
3945
return;
4046
}

src/com/magento/idea/magento2plugin/actions/generation/data/CLICommandClassData.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55

66
package com.magento.idea.magento2plugin.actions.generation.data;
77

8-
public class CLICommandClassData { //NOPMD
8+
@SuppressWarnings({"PMD.CommentSize", "PMD.DataClass"})
9+
public class CLICommandClassData {
910
private final String className;
1011
private final String parentDirectory;
1112
private final String commandName;

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

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,31 @@
22
* Copyright © Magento, Inc. All rights reserved.
33
* See COPYING.txt for license details.
44
*/
5+
56
package com.magento.idea.magento2plugin.actions.generation.dialog;
67

78
import com.magento.idea.magento2plugin.bundles.CommonBundle;
8-
9-
import javax.swing.*;
10-
import java.awt.*;
9+
import java.awt.Dimension;
10+
import java.awt.Toolkit;
11+
import javax.swing.JDialog;
1112

1213
/**
13-
* All code generate dialog should extend this class
14+
* All code generate dialog should extend this class.
1415
*/
16+
@SuppressWarnings({"PMD.ShortVariable", "PMD.MissingSerialVersionUID"})
1517
public abstract class AbstractDialog extends JDialog {
1618

1719
protected CommonBundle bundle;
1820

1921
public AbstractDialog() {
22+
super();
2023
this.bundle = new CommonBundle();
2124
}
2225

23-
protected void centerDialog(AbstractDialog dialog) {
24-
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
25-
int x = screenSize.width / 2 - dialog.getSize().width / 2;
26-
int y = screenSize.height / 2 - dialog.getSize().height / 2;
26+
protected void centerDialog(final AbstractDialog dialog) {
27+
final Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
28+
final int x = screenSize.width / 2 - dialog.getSize().width / 2;
29+
final int y = screenSize.height / 2 - dialog.getSize().height / 2;
2730
dialog.setLocation(x, y);
2831
}
2932

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

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,13 @@
3030
import javax.swing.KeyStroke;
3131
import org.jetbrains.annotations.NotNull;
3232

33-
public class CreateAnObserverDialog extends AbstractDialog { //NOPMD
33+
@SuppressWarnings({
34+
"PMD.TooManyFields",
35+
"PMD.MissingSerialVersionUID",
36+
"PMD.DataClass",
37+
"PMD.UnusedPrivateField",
38+
})
39+
public class CreateAnObserverDialog extends AbstractDialog {
3440
@NotNull
3541
private final Project project;
3642
@NotNull
@@ -44,11 +50,11 @@ public class CreateAnObserverDialog extends AbstractDialog { //NOPMD
4450
private FilteredComboBox observerModule;
4551
private JComboBox observerArea;
4652
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
53+
private JLabel observerClassNameLabel;
54+
private JLabel observerDirectoryName;
55+
private JLabel selectObserverModule;
56+
private JLabel observerAreaLabel;
57+
private JLabel observerNameLabel;
5258

5359
/**
5460
* Constructor.
@@ -73,6 +79,7 @@ public CreateAnObserverDialog(@NotNull final Project project, final String targe
7379

7480
setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
7581
addWindowListener(new WindowAdapter() {
82+
@Override
7683
public void windowClosing(final WindowEvent event) {
7784
onCancel();
7885
}

src/com/magento/idea/magento2plugin/actions/generation/dialog/NewCLICommandDialog.form

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@
66
<xy x="20" y="20" width="904" height="497"/>
77
</constraints>
88
<properties>
9-
<minimumSize width="597" height="497"/>
9+
<minimumSize width="497" height="397"/>
1010
<opaque value="false"/>
11+
<preferredSize width="411" height="312"/>
1112
</properties>
1213
<border type="none"/>
1314
<children>
@@ -40,7 +41,9 @@
4041
<preferred-size width="150" height="-1"/>
4142
</grid>
4243
</constraints>
43-
<properties/>
44+
<properties>
45+
<text resource-bundle="magento2/common" key="common.defaultConsoleDirectory"/>
46+
</properties>
4447
</component>
4548
<component id="a06d9" class="javax.swing.JTextField" binding="cliCommandNameField">
4649
<constraints>
@@ -131,6 +134,7 @@
131134
</grid>
132135
</constraints>
133136
<properties>
137+
<lineWrap value="true"/>
134138
<wrapStyleWord value="false"/>
135139
</properties>
136140
</component>

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,13 @@
2828
import javax.swing.JTextField;
2929
import javax.swing.KeyStroke;
3030

31+
@SuppressWarnings({"PMD.MissingSerialVersionUID"})
3132
public class NewCLICommandDialog extends AbstractDialog {
3233
private JPanel contentPane;
33-
private JTextField cliCommandClassNameField;//NOPMD
34-
private JTextField cliCommandParentDirectoryField;//NOPMD
35-
private JTextField cliCommandNameField;//NOPMD
36-
private JTextArea cliCommandDescriptionField;//NOPMD
34+
private JTextField cliCommandClassNameField;
35+
private JTextField cliCommandParentDirectoryField;
36+
private JTextField cliCommandNameField;
37+
private JTextArea cliCommandDescriptionField;
3738
private JButton buttonCancel;
3839
private JButton buttonOK;
3940

0 commit comments

Comments
 (0)