SDA SE Wiki

Software Engineering for Smart Data Analytics & Smart Data Analytics for Software Engineering

User Tools

Site Tools


Cor 115 and Cor 118 -(SA_SELF_COMPUTATION)

Nonsensical self computation(e.g., x & x)

Inspired by

Original Description

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

Detailed Description

It makes no sense if we use the same variable (field, local variable or parameter) in both side of the following binary operators:

  • -, /, %
  • &&, ||, &, |, ^

Sample Problem Scenario

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>

Sample Counter Scenario

<code Java> public static void dontFindThis(int x) {

   int y=0;
   y=x+x;

} </Code>

Evaluation Results

Benchmark project Precision Recall
FB JT Delta FB JT Delta
Project … …% …% …% …% …% …%
Project … …% …% …% …% …% …%

FB = FindBugs, JT = JTransformer, Delta = JTransformer - FindBugs

teaching/labs/mdse/2013/bug_descriptions/jt-bug-cor115_and_jt-bug-cor118.txt · Last modified: 2018/05/09 01:59 (external edit)

SEWiki, © 2023