Software Engineering for Smart Data Analytics & Smart Data Analytics for Software Engineering
Nonsensical self computation(e.g., x & x)
SA_FIELD_SELF_COMPUTATION:“This method performs a nonsensical computation of a field with another reference to the same field (e.g., x&x or x-x). Because of the nature of the computation, this operation doesn't seem to make sense, and may indicate a typo or a logic error. Double check the computation.” – 2013-12-09
SA_LOCAL_SELF_COMPUTATION:“This method performs a nonsensical computation of a local variable with another reference to the same variable (e.g., x&x or x-x). Because of the nature of the computation, this operation doesn't seem to make sense, and may indicate a typo or a logic error. Double check the computation.” – 2013-12-09
It makes no sense if we use the same variable (field, local variable or parameter) in both side of the following binary operators:
In following part we have an example: <code Java> public class test {
static int y=0; public static void findThis(int x) { y=x-x; //cor118 x=y-y; //cor115 }
} </Code>
<code Java> public static void dontFindThis(int x) {
int y=0; y=x+x;
} </Code>
Benchmark project | Precision | Recall | ||||
---|---|---|---|---|---|---|
FB | JT | Delta | FB | JT | Delta | |
Project … | …% | …% | …% | …% | …% | …% |
Project … | …% | …% | …% | …% | …% | …% |
FB = FindBugs, JT = JTransformer, Delta = JTransformer - FindBugs