Files
openide/java/java-tests/testData/inspection/dataFlow/fixture/ArithmeticNoOp.java
Tagir Valeev d471e3e863 Report expressions that evaluate to zero in dataflow
Fixes IDEA-143315 Extend 'constant conditions' inspection to detect difference of equal expressions

GitOrigin-RevId: 789417deba774b3a77f2634c8edeb63876660b76
2020-03-18 10:02:22 +00:00

28 lines
1005 B
Java

import java.util.*;
public class ArithmeticNoOp {
void test(long x, int y) {
if(y == 1) {
long z = x * y;
long t = x / y;
long u = y / z;
long w = y * z;
if (<warning descr="Condition 'z == x' is always 'true'">z == x</warning>) {}
if (<warning descr="Condition 't == x' is always 'true'">t == x</warning>) {}
if (<warning descr="Condition 'w == x' is always 'true'">w == x</warning>) {}
if (u == x) {}
}
if(y == 0) {
long a = x >> y;
long b = x << y;
long c = x >>> y;
long d = <warning descr="Result of 'y >>> x' is always '0'">y >>> x</warning>;
if (<warning descr="Condition 'a == x' is always 'true'">a == x</warning>) {}
if (<warning descr="Condition 'b == x' is always 'true'">b == x</warning>) {}
if (<warning descr="Condition 'c == x' is always 'true'">c == x</warning>) {}
if (d == x) {}
if (<warning descr="Condition 'd == y' is always 'true'">d == y</warning>) {}
}
}
}