Skip to content

Commit a625f4b

Browse files
Merge pull request #816 from bohdan-harniuk/bugfix/739-empty-psi-elements-plugin-inspections
Bugfix-739: Fixed empty psi elements in the plugin inspections
2 parents caf1a28 + 100f04a commit a625f4b

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/com/magento/idea/magento2plugin/inspections/php/PluginInspection.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,13 @@
3030
import java.util.ArrayList;
3131
import org.jetbrains.annotations.NotNull;
3232

33-
@SuppressWarnings({"PMD.ExcessiveMethodLength", "PMD.NPathComplexity"})
33+
@SuppressWarnings({"PMD.ExcessiveMethodLength", "PMD.NPathComplexity", "PMD.CognitiveComplexity"})
3434
public class PluginInspection extends PhpInspection {
3535

3636
private static final String WRONG_PARAM_TYPE = "inspection.wrong_param_type";
3737

38-
@NotNull
3938
@Override
40-
public PsiElementVisitor buildVisitor(
39+
public @NotNull PsiElementVisitor buildVisitor(
4140
final @NotNull ProblemsHolder problemsHolder,
4241
final boolean isOnTheFly
4342
) {
@@ -146,7 +145,7 @@ private void checkTargetMethod(
146145
final String targetClassMethodName,
147146
final Method targetMethod
148147
) {
149-
if (targetClassMethodName.equals(MagentoPhpClass.CONSTRUCT_METHOD_NAME)) {
148+
if (MagentoPhpClass.CONSTRUCT_METHOD_NAME.equals(targetClassMethodName)) {
150149
problemsHolder.registerProblem(
151150
pluginMethod.getNameIdentifier(),
152151
inspectionBundle.message("inspection.plugin.error.constructMethod"),
@@ -167,7 +166,7 @@ private void checkTargetMethod(
167166
ProblemHighlightType.ERROR
168167
);
169168
}
170-
if (!targetMethod.getAccess().toString().equals(AbstractPhpFile.PUBLIC_ACCESS)) {
169+
if (!AbstractPhpFile.PUBLIC_ACCESS.equals(targetMethod.getAccess().toString())) {
171170
problemsHolder.registerProblem(
172171
pluginMethod.getNameIdentifier(),
173172
inspectionBundle.message("inspection.plugin.error.nonPublicMethod"),
@@ -187,6 +186,9 @@ private void checkParametersCompatibility(
187186

188187
int index = 0;
189188
for (final Parameter pluginMethodParameter : pluginMethodParameters) {
189+
if (pluginMethodParameter.getName().isEmpty()) {
190+
continue;
191+
}
190192
index++;
191193
String declaredType = pluginMethodParameter.getDeclaredType().toString();
192194

@@ -276,7 +278,7 @@ private void checkParametersCompatibility(
276278
if (declaredType.isEmpty()) {
277279
continue;
278280
}
279-
if (!declaredType.equals(MagentoPhpClass.PHP_NULL)) {
281+
if (!MagentoPhpClass.PHP_NULL.equals(declaredType)) {
280282
problemsHolder.registerProblem(
281283
pluginMethodParameter,
282284
PhpBundle.message(

0 commit comments

Comments
 (0)