Software Engineering for Smart Data Analytics & Smart Data Analytics for Software Engineering
“This method compares an expression of the form (e & 0) to 0, which will always compare equal. This may indicate a logic error or typo.” – 2013-10-28
When ever a value is bitwise conjoined with zero (x & 0 ) the result is ALWAYS zero. That means there is no need to compare the result afterwards if it really is zero.
<code Java>
int x = 131; if((x & 0) == 0){ System.out.println("This will always happen"); }
</Code>
<code Java>
int x = 131; if((x | 0) == 0){ System.out.println("This might happen"); }
</Code>
There is no meaningful fix that we can offer. The programmer has to understand herself the logic error or typo and correct it manually.
Benchmark project | Precision | Recall | ||||
---|---|---|---|---|---|---|
FB | JT | Delta | FB | JT | Delta | |
Apache Tomcat | 100% | 100% | 0 | 100% | 100% | 0 |
Argo UML | 100% | 100% | 0 | 100% | 100% | 0 |
AWT | 100% | 100% | 0 | 100% | 100% | 0 |
Jakarta | 100% | 100% | 0 | 100% | 100% | 0 |
Java IO | 100% | 100% | 0 | 100% | 100% | 0 |
JHotDraw | 100% | 100% | 0 | 100% | 100% | 0 |
jrefactory | 100% | 100% | 0 | 100% | 100% | 0 |
JServlet | 100% | 100% | 0 | 100% | 100% | 0 |
JUnit | 100% | 100% | 0 | 100% | 100% | 0 |
Lexi | 100% | 100% | 0 | 100% | 100% | 0 |
Mapper XML | 100% | 100% | 0 | 100% | 100% | 0 |
nutch | 100% | 100% | 0 | 100% | 100% | 0 |
PMD | 100% | 100% | 0 | 100% | 100% | 0 |
quickuml | 100% | 100% | 0 | 100% | 100% | 0 |
FB = FindBugs, JT = JTransformer, Delta = JTransformer - FindBug