mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IG: "Method parameter naming convention" inspection should not warn on lambda parameters
This commit is contained in:
+4
-6
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -15,10 +15,7 @@
|
||||
*/
|
||||
package com.siyeh.ig.naming;
|
||||
|
||||
import com.intellij.psi.PsiCatchSection;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiForeachStatement;
|
||||
import com.intellij.psi.PsiParameter;
|
||||
import com.intellij.psi.*;
|
||||
import com.siyeh.InspectionGadgetsBundle;
|
||||
import com.siyeh.ig.BaseInspectionVisitor;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -90,7 +87,8 @@ public class ParameterNamingConventionInspectionBase extends ConventionInspectio
|
||||
public void visitParameter(@NotNull PsiParameter variable) {
|
||||
final PsiElement scope = variable.getDeclarationScope();
|
||||
if (scope instanceof PsiCatchSection ||
|
||||
scope instanceof PsiForeachStatement) {
|
||||
scope instanceof PsiForeachStatement ||
|
||||
scope instanceof PsiLambdaExpression) {
|
||||
return;
|
||||
}
|
||||
final String name = variable.getName();
|
||||
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
package com.siyeh.igtest.naming.parameter_naming_convention;
|
||||
|
||||
public class ParameterNamingConvention {
|
||||
|
||||
void m(int <warning descr="Parameter name 'a' is too short">a</warning>) {}
|
||||
void n(int abcd) {
|
||||
F f = (i) -> 10;
|
||||
}
|
||||
|
||||
interface F {
|
||||
int a(int <warning descr="Parameter name 'i' is too short">i</warning>);
|
||||
}
|
||||
|
||||
}
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.siyeh.ig.naming;
|
||||
|
||||
import com.intellij.codeInspection.InspectionProfileEntry;
|
||||
import com.siyeh.ig.LightInspectionTestCase;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* @author Bas Leijdekkers
|
||||
*/
|
||||
public class ParameterNamingConventionInspectionTest extends LightInspectionTestCase {
|
||||
|
||||
public void testParameterNamingConvention() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
protected InspectionProfileEntry getInspection() {
|
||||
final ParameterNamingConventionInspection inspection = new ParameterNamingConventionInspection();
|
||||
inspection.m_minLength = 3;
|
||||
inspection.m_maxLength = 5;
|
||||
return inspection;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user