mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
OverflowingLoopInspection: do not highlight in case of -=- 1
This commit is contained in:
@@ -135,9 +135,9 @@ public class OverflowingLoopIndexInspection extends AbstractBaseJavaLocalInspect
|
||||
boolean negative = number.longValue() < 0;
|
||||
IElementType op = assignment.getOperationTokenType();
|
||||
if (conditionType == ConditionType.VarGreater) {
|
||||
return op == JavaTokenType.PLUSEQ || (op == JavaTokenType.MINUSEQ && negative);
|
||||
return (op == JavaTokenType.PLUSEQ && !negative) || (op == JavaTokenType.MINUSEQ && negative);
|
||||
} else {
|
||||
return op == JavaTokenType.MINUSEQ || (op == JavaTokenType.PLUSEQ && negative);
|
||||
return (op == JavaTokenType.MINUSEQ && !negative) || (op == JavaTokenType.PLUSEQ && negative);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -30,7 +30,7 @@ public class OverflowingLoop {
|
||||
}
|
||||
|
||||
void minusEqAddNegative(int s) {
|
||||
<warning descr="Loop executes zero or billions times">for</warning> (int i = s; i > 12; i += -12) {
|
||||
for (int i = s; i > 12; i += -12) {
|
||||
System.out.println(i + 23);
|
||||
}
|
||||
}
|
||||
@@ -61,4 +61,10 @@ public class OverflowingLoop {
|
||||
i+= 100;
|
||||
}
|
||||
}
|
||||
|
||||
void minusEqMinus(int s) {
|
||||
for (int i = 0; i < 10; i -=- 1) {
|
||||
System.out.println("asdsakdj");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user