mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-188088 Suspicious parameter/name combination does not work for camelCaseWords
This commit is contained in:
+14
-10
@@ -61,7 +61,7 @@ public class SuspiciousNameCombinationInspectionBase extends AbstractBaseJavaLoc
|
||||
myWordToGroupMap.clear();
|
||||
}
|
||||
|
||||
protected void addNameGroup(@NonNls final String group) {
|
||||
public void addNameGroup(@NonNls final String group) {
|
||||
myNameGroups.add(group);
|
||||
List<String> words = StringUtil.split(group, ",");
|
||||
for(String word: words) {
|
||||
@@ -197,15 +197,19 @@ public class SuspiciousNameCombinationInspectionBase extends AbstractBaseJavaLoc
|
||||
}
|
||||
String[] words = NameUtil.splitNameIntoWords(name);
|
||||
String result = null;
|
||||
for(String word: words) {
|
||||
String group = myWordToGroupMap.get(canonicalize(word));
|
||||
if (group != null) {
|
||||
if (result == null) {
|
||||
result = group;
|
||||
}
|
||||
else if (!result.equals(group)) {
|
||||
result = null;
|
||||
break;
|
||||
for (int i = 0; i < words.length; i++) {
|
||||
String word = "";
|
||||
for (int j = i; j < words.length; j++) {
|
||||
word += words[j];
|
||||
String group = myWordToGroupMap.get(canonicalize(word));
|
||||
if (group != null) {
|
||||
if (result == null) {
|
||||
result = group;
|
||||
}
|
||||
else if (!result.equals(group)) {
|
||||
result = null;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
public class TwoWords {
|
||||
public void test() {
|
||||
int someWord = 0, theOtherWord = 1, someWord123 = 2;
|
||||
int <warning descr="'someWord' should probably not be assigned to 'x'">x</warning> = someWord;
|
||||
int <warning descr="'theOtherWord' should probably not be assigned to 'y'">y</warning> = theOtherWord;
|
||||
someWord123 = someWord;
|
||||
theOtherWord = someWord;
|
||||
}
|
||||
}
|
||||
+4
-1
@@ -34,7 +34,9 @@ public class SuspiciousNameCombinationTest extends LightInspectionTestCase {
|
||||
@Nullable
|
||||
@Override
|
||||
protected InspectionProfileEntry getInspection() {
|
||||
return new SuspiciousNameCombinationInspection();
|
||||
SuspiciousNameCombinationInspection inspection = new SuspiciousNameCombinationInspection();
|
||||
inspection.addNameGroup("someWord,otherWord");
|
||||
return inspection;
|
||||
}
|
||||
|
||||
public void testAssignment() { doTest();}
|
||||
@@ -42,4 +44,5 @@ public class SuspiciousNameCombinationTest extends LightInspectionTestCase {
|
||||
public void testParameter() { doTest();}
|
||||
public void testReturnValue() { doTest();}
|
||||
public void testExcluded() { doTest();}
|
||||
public void testTwoWords() { doTest();}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user