Skip to content

Commit ce1c9a8

Browse files
author
Sergiy Zhovnir
committed
#issue-178 Fixed static tests
1 parent 13b7b34 commit ce1c9a8

File tree

6 files changed

+34
-24
lines changed

6 files changed

+34
-24
lines changed

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,19 +29,20 @@ public NewCronGroupAction() {
2929

3030
@Override
3131
public void actionPerformed(final AnActionEvent event) {
32-
DataContext dataContext = event.getDataContext();
33-
IdeView view = LangDataKeys.IDE_VIEW.getData(dataContext);
32+
final DataContext dataContext = event.getDataContext();
33+
final IdeView view = LangDataKeys.IDE_VIEW.getData(dataContext);
3434

3535
if (view == null) {
3636
return;
3737
}
3838

39-
Project project = CommonDataKeys.PROJECT.getData(dataContext);
39+
final Project project = CommonDataKeys.PROJECT.getData(dataContext);
4040
if (project == null) {
4141
return;
4242
}
4343

44-
PsiDirectory directory = view.getOrChooseDirectory();
44+
final PsiDirectory directory = view.getOrChooseDirectory();
45+
4546
if (directory == null) {
4647
return;
4748
}

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

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

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

8+
@SuppressWarnings({"PMD.DataClass"})
89
public class CronGroupXmlData {
910
private final String module;
1011
private final String groupName;
@@ -30,15 +31,15 @@ public class CronGroupXmlData {
3031
* @param useSeparateProcess Use separate process
3132
*/
3233
public CronGroupXmlData(
33-
String module,
34-
String groupName,
35-
Integer scheduleGenerateEvery,
36-
Integer scheduleAheadFor,
37-
Integer scheduleLifetime,
38-
Integer historyCleanupEvery,
39-
Integer historySuccessLifetime,
40-
Integer historyFailureLifetime,
41-
Integer useSeparateProcess
34+
final String module,
35+
final String groupName,
36+
final Integer scheduleGenerateEvery,
37+
final Integer scheduleAheadFor,
38+
final Integer scheduleLifetime,
39+
final Integer historyCleanupEvery,
40+
final Integer historySuccessLifetime,
41+
final Integer historyFailureLifetime,
42+
final Integer useSeparateProcess
4243
) {
4344
this.module = module;
4445
this.groupName = groupName;

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@
2727
import javax.swing.JTextField;
2828
import javax.swing.KeyStroke;
2929

30+
@SuppressWarnings({
31+
"PMD.TooManyFields",
32+
"PMD.TooManyMethods"
33+
})
3034
public class NewCronGroupDialog extends AbstractDialog {
3135
private final NewCronGroupValidator validator;
3236
private final String moduleName;
@@ -57,6 +61,7 @@ public class NewCronGroupDialog extends AbstractDialog {
5761
* @param directory Directory
5862
*/
5963
public NewCronGroupDialog(final Project project, final PsiDirectory directory) {
64+
super();
6065
this.project = project;
6166
setContentPane(contentPanel);
6267
setModal(true);
@@ -90,6 +95,7 @@ public void windowClosing(final WindowEvent event) {
9095
*
9196
* @return CronGroupXmlData
9297
*/
98+
@SuppressWarnings({"PMD.NullAssignment"})
9399
public CronGroupXmlData getCronGroupXmlData() {
94100
return new CronGroupXmlData(
95101
getModuleName(),
@@ -249,6 +255,7 @@ private Boolean getAddUseSeparateProcess() {
249255
return addUseSeparateProcess.isSelected();
250256
}
251257

258+
@SuppressWarnings({"PMD.UnusedPrivateMethod"})
252259
private void createUIComponents() {
253260
this.useSeparateProcess = new FilteredComboBox(getYesNoOptions());
254261
}

src/com/magento/idea/magento2plugin/actions/generation/dialog/validator/NewCronGroupValidator.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212
import com.magento.idea.magento2plugin.util.RegExUtil;
1313
import javax.swing.JOptionPane;
1414

15-
@SuppressWarnings({"PMD.OnlyOneReturn"})
15+
@SuppressWarnings({"PMD.OnlyOneReturn", "PMD.NonThreadSafeSingleton"})
1616
public class NewCronGroupValidator {
1717
private static final String MUST_NOT_BE_NEGATIVE = "validator.mustNotBeNegative";
18-
private static NewCronGroupValidator INSTANCE;
18+
private static NewCronGroupValidator instance;
1919
private final ValidatorBundle validatorBundle;
2020
private final CommonBundle commonBundle;
2121

@@ -25,11 +25,11 @@ public class NewCronGroupValidator {
2525
* @return NewCronGroupValidator
2626
*/
2727
public static NewCronGroupValidator getInstance() {
28-
if (null == INSTANCE) {
29-
INSTANCE = new NewCronGroupValidator();
28+
if (null == instance) {
29+
instance = new NewCronGroupValidator();
3030
}
3131

32-
return INSTANCE;
32+
return instance;
3333
}
3434

3535
/**

src/com/magento/idea/magento2plugin/actions/generation/generator/ModuleCronGroupXmlGenerator.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import java.util.Properties;
3030
import javax.swing.JOptionPane;
3131

32+
@SuppressWarnings({"PMD.AvoidPrintStackTrace"})
3233
public class ModuleCronGroupXmlGenerator extends FileGenerator {
3334
private final CronGroupXmlData cronGroupXmlData;
3435
private final Project project;
@@ -101,8 +102,8 @@ public PsiFile generate(final String actionName) {
101102
);
102103

103104
textBuf.append(cronjobRegistrationTemplate);
104-
} catch (final IOException e) {
105-
e.printStackTrace();
105+
} catch (final IOException exception) {
106+
exception.printStackTrace();
106107
return;
107108
}
108109

@@ -144,7 +145,7 @@ public PsiFile generate(final String actionName) {
144145
}
145146

146147
document.insertString(insertPos, textBuf);
147-
int endPos = insertPos + textBuf.length() + 1;
148+
final int endPos = insertPos + textBuf.length() + 1;
148149

149150
this.codeStyleManager.reformatText(cronGroupXmlFile, insertPos, endPos);
150151
this.psiDocumentManager.commitDocument(document);
@@ -220,13 +221,13 @@ protected void fillAttributes(final Properties attributes) {
220221
* @return XmlTag
221222
*/
222223
private XmlTag getCronGroupTag(final XmlFile cronGroupXmlFile, final String cronGroupName) {
223-
Collection<XmlAttributeValue> attributes = XmlPsiTreeUtil.findAttributeValueElements(
224+
final Collection<XmlAttributeValue> attributes = XmlPsiTreeUtil.findAttributeValueElements(
224225
cronGroupXmlFile,
225226
CrontabXmlTemplate.CRON_GROUP_TAG,
226227
CrontabXmlTemplate.CRON_GROUP_NAME_ATTRIBUTE
227228
);
228229

229-
for (XmlAttributeValue cronGroupIdAttribute: attributes) {
230+
for (final XmlAttributeValue cronGroupIdAttribute: attributes) {
230231
if (!cronGroupIdAttribute.getValue().equals(cronGroupName)) {
231232
continue;
232233
}

src/com/magento/idea/magento2plugin/actions/generation/generator/util/FindOrCreateCronGroupXml.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public PsiFile execute(final String actionName, final String moduleName) {
4949

5050
fileDirectories.add(Package.moduleBaseAreaDir);
5151

52-
for (String fileDirectory: fileDirectories) {
52+
for (final String fileDirectory: fileDirectories) {
5353
parentDirectory = this.directoryGenerator.findOrCreateSubdirectory(
5454
parentDirectory,
5555
fileDirectory

0 commit comments

Comments
 (0)