Skip to content

Commit 58abe4f

Browse files
Fixed static checks issues
1 parent 6de9a0e commit 58abe4f

File tree

3 files changed

+13
-23
lines changed

3 files changed

+13
-23
lines changed

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public abstract class PluginGenerateMethodHandlerBase implements LanguageCodeIns
7272
*/
7373
public PluginGenerateMethodHandlerBase(final Plugin.PluginType type) {
7474
this.type = type.toString();
75-
this.fillTextBuffer = FillTextBufferWithPluginMethods.getInstance();
75+
this.fillTextBuffer = new FillTextBufferWithPluginMethods();
7676
this.collectInsertedMethods = CollectInsertedMethods.getInstance();
7777
this.validatorBundle = new ValidatorBundle();
7878
this.commonBundle = new CommonBundle();

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public PluginClassGenerator(
7373
this.directoryGenerator = DirectoryGenerator.getInstance();
7474
this.fileFromTemplateGenerator = new FileFromTemplateGenerator(project);
7575
this.getFirstClassOfFile = GetFirstClassOfFile.getInstance();
76-
this.fillTextBuffer = FillTextBufferWithPluginMethods.getInstance();
76+
this.fillTextBuffer = new FillTextBufferWithPluginMethods();
7777
this.collectInsertedMethods = CollectInsertedMethods.getInstance();
7878
this.pluginFileData = pluginFileData;
7979
this.project = project;

src/com/magento/idea/magento2plugin/actions/generation/util/FillTextBufferWithPluginMethods.java

+11-21
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,6 @@
2020
import org.jetbrains.annotations.NotNull;
2121

2222
public class FillTextBufferWithPluginMethods {
23-
private static FillTextBufferWithPluginMethods INSTANCE = null;
24-
25-
/**
26-
* Get util instance.
27-
*
28-
* @return FillTextBufferWithPluginMethods
29-
*/
30-
public static FillTextBufferWithPluginMethods getInstance() {
31-
if (null == INSTANCE) {
32-
INSTANCE = new FillTextBufferWithPluginMethods();
33-
}
34-
return INSTANCE;
35-
}
3623

3724
/**
3825
* Fill text buffer with plugin methods.
@@ -43,27 +30,30 @@ public static FillTextBufferWithPluginMethods getInstance() {
4330
* @param textBuf StringBuffer
4431
* @param pluginMethods PluginMethodData
4532
*/
33+
@SuppressWarnings("PMD.AvoidInstantiatingObjectsInLoops")
4634
public void execute(
4735
final @NotNull Key<Object> targetClassKey,
4836
final Set<CharSequence> insertedMethodsNames,
4937
final @NotNull PhpClassReferenceResolver resolver,
5038
final @NotNull StringBuffer textBuf,
51-
final @NotNull PluginMethodData[] pluginMethods
39+
final @NotNull PluginMethodData... pluginMethods
5240
) {
53-
for (PluginMethodData pluginMethod : pluginMethods) {
41+
for (final PluginMethodData pluginMethod : pluginMethods) {
5442
insertedMethodsNames.add(pluginMethod.getMethod().getName());
55-
PhpDocComment comment = pluginMethod.getDocComment();
43+
final PhpDocComment comment = pluginMethod.getDocComment();
44+
5645
if (comment != null) {
5746
textBuf.append(comment.getText());
5847
}
59-
Method targetMethod = pluginMethod.getTargetMethod();
60-
Parameter[] parameters = targetMethod.getParameters();
61-
Collection<PsiElement> processElements = new ArrayList<>(Arrays.asList(parameters));
48+
final Method targetMethod = pluginMethod.getTargetMethod();
49+
final Parameter[] parameters = targetMethod.getParameters();
50+
final Collection<PsiElement> processElements =
51+
new ArrayList<>(Arrays.asList(parameters));
6252
resolver.processElements(processElements);
63-
PsiElement targetClass = (PsiElement) pluginMethod.getTargetMethod()
53+
final PsiElement targetClass = (PsiElement) pluginMethod.getTargetMethod()
6454
.getUserData(targetClassKey);
6555
resolver.processElement(targetClass);
66-
PhpReturnType returnType = targetMethod.getReturnType();
56+
final PhpReturnType returnType = targetMethod.getReturnType();
6757
if (returnType != null) {
6858
resolver.processElement(returnType);
6959
}

0 commit comments

Comments
 (0)