Skip to content

Commit 47670db

Browse files
committed
Fixed PMD issues
1 parent 6d911e2 commit 47670db

File tree

9 files changed

+52
-82
lines changed

9 files changed

+52
-82
lines changed

src/com/magento/idea/magento2plugin/magento/files/BlockPhp.java

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,20 @@
99
import com.jetbrains.php.lang.PhpLanguage;
1010

1111
public class BlockPhp implements ModuleFileInterface {
12-
public static String TEMPLATE = "Magento Regular Class";
13-
public static String DEFAULT_DIR = "Block";
14-
public static String STOREFRONT_BLOCK_FQN = "Magento\\Framework\\View\\Element\\Template";
15-
public static String STOREFRONT_BLOCK_NAME = "Template";
12+
public static final String TEMPLATE = "Magento Regular Class";
13+
public static final String DEFAULT_DIR = "Block";
14+
public static final String STOREFRONT_BLOCK_FQN = "Magento\\Framework\\View\\Element\\Template";
15+
public static final String STOREFRONT_BLOCK_NAME = "Template";
1616

17-
private static BlockPhp INSTANCE = null;
17+
private static final BlockPhp INSTANCE = new BlockPhp();
1818
private String fileName;
1919

2020
/**
2121
* Getter for singleton instance of class.
2222
*/
23-
public static BlockPhp getInstance(String className) {
24-
if (null == INSTANCE) {
25-
INSTANCE = new BlockPhp();
26-
}
27-
INSTANCE.setFileName(className.concat(".php"));
23+
public static BlockPhp getInstance(final String className) {
24+
INSTANCE.fileName = className.concat(".php");
25+
2826
return INSTANCE;
2927
}
3028

@@ -42,8 +40,4 @@ public String getTemplate() {
4240
public Language getLanguage() {
4341
return PhpLanguage.INSTANCE;
4442
}
45-
46-
private void setFileName(String filename) {
47-
this.fileName = filename;
48-
}
4943
}

src/com/magento/idea/magento2plugin/magento/files/ComposerJson.java

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,16 @@
99
import com.intellij.lang.Language;
1010

1111
public class ComposerJson implements ModuleFileInterface {
12-
public static String FILE_NAME = "composer.json";
13-
public static String TEMPLATE = "Magento Composer JSON";
14-
public static String DEFAULT_DEPENDENCY = "\"magento/framework\": \"*\"";
15-
public static String NO_DEPENDENCY_LABEL = "None";
16-
private static ComposerJson INSTANCE = null;
12+
public static final String FILE_NAME = "composer.json";
13+
public static final String TEMPLATE = "Magento Composer JSON";
14+
public static final String DEFAULT_DEPENDENCY = "\"magento/framework\": \"*\"";
15+
public static final String NO_DEPENDENCY_LABEL = "None";
16+
private static final ComposerJson INSTANCE = new ComposerJson();
1717

1818
/**
1919
* Getter for singleton instance of class.
2020
*/
2121
public static ComposerJson getInstance() {
22-
if (null == INSTANCE) {
23-
INSTANCE = new ComposerJson();
24-
}
2522
return INSTANCE;
2623
}
2724

src/com/magento/idea/magento2plugin/magento/files/CronjobTemplate.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99
import com.jetbrains.php.lang.PhpLanguage;
1010

1111
public class CronjobTemplate implements ModuleFileInterface {
12-
private String fileName;
12+
private String fileName;// NOPMD
1313

14-
public CronjobTemplate(String className) {
15-
fileName = className.concat(".php");
14+
public CronjobTemplate(final String className) {
15+
this.fileName = className.concat(".php");
1616
}
1717

1818
@Override

src/com/magento/idea/magento2plugin/magento/files/CrontabXmlTemplate.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,18 @@
99
import com.intellij.lang.xml.XMLLanguage;
1010

1111
public class CrontabXmlTemplate implements ModuleFileInterface {
12-
public static String FILE_NAME = "crontab.xml";
13-
public static String TEMPLATE = "Magento Cron Tab XML";
12+
public static final String FILE_NAME = "crontab.xml";
13+
public static final String TEMPLATE = "Magento Cron Tab XML";
1414

1515
// code templates
16-
public static String TEMPLATE_CRONJOB_REGISTRATION = "Magento Crontab Cronjob Registration";
16+
public static final String TEMPLATE_CRONJOB_REGISTRATION
17+
= "Magento Crontab Cronjob Registration";
1718

1819
// XML definitions
19-
public static String CRON_GROUP_TAG = "group";
20-
public static String CRON_GROUP_NAME_ATTRIBUTE = "id";
21-
public static String CRON_JOB_TAG = "job";
22-
public static String CRON_JOB_NAME_ATTRIBUTE = "name";
20+
public static final String CRON_GROUP_TAG = "group";
21+
public static final String CRON_GROUP_NAME_ATTRIBUTE = "id";
22+
public static final String CRON_JOB_TAG = "job";
23+
public static final String CRON_JOB_NAME_ATTRIBUTE = "name";
2324

2425
@Override
2526
public String getFileName() {

src/com/magento/idea/magento2plugin/magento/files/ModuleEventsXml.java

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,26 +9,23 @@
99
import com.intellij.lang.xml.XMLLanguage;
1010

1111
public class ModuleEventsXml implements ModuleFileInterface {
12-
public static String FILE_NAME = "events.xml";
13-
public static String TEMPLATE = "Magento Events XML";
12+
public static final String FILE_NAME = "events.xml";
13+
public static final String TEMPLATE = "Magento Events XML";
1414

1515
//code templates
16-
public static String TEMPLATE_OBSERVER = "Magento Module Events Xml Observer";
16+
public static final String TEMPLATE_OBSERVER = "Magento Module Events Xml Observer";
1717

1818
//tags
19-
public static String OBSERVER_TAG = "observer";
20-
public static String INSTANCE_ATTRIBUTE = "instance";
21-
public static String EVENT_TAG = "event";
19+
public static final String OBSERVER_TAG = "observer";
20+
public static final String INSTANCE_ATTRIBUTE = "instance";
21+
public static final String EVENT_TAG = "event";
2222

23-
private static ModuleEventsXml INSTANCE = null;
23+
private static final ModuleEventsXml INSTANCE = new ModuleEventsXml();
2424

2525
/**
2626
* Getter for singleton instance of class.
2727
*/
2828
public static ModuleEventsXml getInstance() {
29-
if (null == INSTANCE) {
30-
INSTANCE = new ModuleEventsXml();
31-
}
3229
return INSTANCE;
3330
}
3431

src/com/magento/idea/magento2plugin/magento/files/ModuleXml.java

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,15 @@
99
import com.intellij.lang.xml.XMLLanguage;
1010

1111
public class ModuleXml implements ModuleFileInterface {
12-
public static String FILE_NAME = "module.xml";
13-
public static String MODULE_ATTR_NAME = "name";
14-
public static String TEMPLATE = "Magento Module XML";
15-
private static ModuleXml INSTANCE = null;
12+
public static final String FILE_NAME = "module.xml";
13+
public static final String MODULE_ATTR_NAME = "name";
14+
public static final String TEMPLATE = "Magento Module XML";
15+
private static final ModuleXml INSTANCE = new ModuleXml();
1616

1717
/**
1818
* Getter for singleton instance of class.
1919
*/
2020
public static ModuleXml getInstance() {
21-
if (null == INSTANCE) {
22-
INSTANCE = new ModuleXml();
23-
}
2421
return INSTANCE;
2522
}
2623

src/com/magento/idea/magento2plugin/magento/files/PhpPreference.java

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,16 @@
99
import com.jetbrains.php.lang.PhpLanguage;
1010

1111
public class PhpPreference implements ModuleFileInterface {
12-
public static String TEMPLATE = "Magento Preference Class";
13-
14-
private static PhpPreference INSTANCE = null;
12+
public static final String TEMPLATE = "Magento Preference Class";
1513
private String fileName;
14+
private static final PhpPreference INSTANCE = new PhpPreference();
1615

1716
/**
1817
* Getter for singleton instance of class.
1918
*/
20-
public static PhpPreference getInstance(String className) {
21-
if (null == INSTANCE) {
22-
INSTANCE = new PhpPreference();
23-
}
24-
INSTANCE.setFileName(className.concat(".php"));
19+
public static PhpPreference getInstance(final String className) {
20+
INSTANCE.fileName = className.concat(".php");
21+
2522
return INSTANCE;
2623
}
2724

@@ -39,8 +36,4 @@ public String getTemplate() {
3936
public Language getLanguage() {
4037
return PhpLanguage.INSTANCE;
4138
}
42-
43-
private void setFileName(String filename) {
44-
this.fileName = filename;
45-
}
4639
}

src/com/magento/idea/magento2plugin/magento/files/RegistrationPhp.java

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,15 @@
99
import com.jetbrains.php.lang.PhpLanguage;
1010

1111
public class RegistrationPhp implements ModuleFileInterface {
12-
public static String FILE_NAME = "registration.php";
13-
public static String TEMPLATE = "Magento Registration PHP";
14-
public static String REGISTER_METHOD_NAME = "register";
15-
private static RegistrationPhp INSTANCE = null;
12+
public static final String FILE_NAME = "registration.php";
13+
public static final String TEMPLATE = "Magento Registration PHP";
14+
public static final String REGISTER_METHOD_NAME = "register";
15+
private static final RegistrationPhp INSTANCE = new RegistrationPhp();
1616

1717
/**
1818
* Getter for singleton instance of class.
1919
*/
2020
public static RegistrationPhp getInstance() {
21-
if (null == INSTANCE) {
22-
INSTANCE = new RegistrationPhp();
23-
}
2421
return INSTANCE;
2522
}
2623

src/com/magento/idea/magento2plugin/magento/files/ViewModelPhp.java

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,21 @@
99
import com.jetbrains.php.lang.PhpLanguage;
1010

1111
public class ViewModelPhp implements ModuleFileInterface {
12-
public static String TEMPLATE = "Magento Regular Class";
13-
public static String DEFAULT_DIR = "ViewModel";
14-
public static String INTERFACE_FQN
12+
public static final String TEMPLATE = "Magento Regular Class";
13+
public static final String DEFAULT_DIR = "ViewModel";
14+
public static final String INTERFACE_FQN
1515
= "Magento\\Framework\\View\\Element\\Block\\ArgumentInterface";
16-
public static String INTERFACE_NAME = "ArgumentInterface";
16+
public static final String INTERFACE_NAME = "ArgumentInterface";
1717

18-
private static ViewModelPhp INSTANCE = null;
18+
private static final ViewModelPhp INSTANCE = new ViewModelPhp();
1919
private String fileName;
2020

2121
/**
2222
* Getter for singleton instance of class.
2323
*/
24-
public static ViewModelPhp getInstance(String className) {
25-
if (null == INSTANCE) {
26-
INSTANCE = new ViewModelPhp();
27-
}
28-
INSTANCE.setFileName(className.concat(".php"));
24+
public static ViewModelPhp getInstance(final String className) {
25+
INSTANCE.fileName = className.concat(".php");
26+
2927
return INSTANCE;
3028
}
3129

@@ -43,8 +41,4 @@ public String getTemplate() {
4341
public Language getLanguage() {
4442
return PhpLanguage.INSTANCE;
4543
}
46-
47-
private void setFileName(String filename) {
48-
this.fileName = filename;
49-
}
5044
}

0 commit comments

Comments
 (0)