mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-121920 (X/X can be replaced with X - incorrect arithmetic)
This commit is contained in:
+1
-1
@@ -120,7 +120,7 @@ public class PointlessArithmeticExpressionInspection
|
||||
}
|
||||
}
|
||||
else if (tokenType.equals(JavaTokenType.DIV)) {
|
||||
if (ExpressionUtils.isOne(expression)) {
|
||||
if (ExpressionUtils.isOne(rhs)) {
|
||||
return lhs.getText();
|
||||
}
|
||||
return "1";
|
||||
|
||||
+2
@@ -110,4 +110,6 @@ class Main {
|
||||
final Main main = new Main(12);
|
||||
return (CONST + (new Main(5).i) * 8) - (Main.CONST + new Main(5).i * (8));
|
||||
}
|
||||
|
||||
int one = 5/5;
|
||||
}
|
||||
+7
@@ -147,4 +147,11 @@
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Pointless arithmetic expression</problem_class>
|
||||
<description><code>(CONST + (new Main(5).i) * 8) - (Main.CONST + new Main(5).i * (8))</code> can be replaced with '0' #loc</description>
|
||||
</problem>
|
||||
|
||||
<problem>
|
||||
<file>PointlessArithmeticExpression.java</file>
|
||||
<line>114</line>
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Pointless arithmetic expression</problem_class>
|
||||
<description><code>5/5</code> can be replaced with '1' #loc</description>
|
||||
</problem>
|
||||
</problems>
|
||||
Reference in New Issue
Block a user