cqfn / veniq

Veniq uses Machine Learning to analyze source code, find possible refactorings, and suggest those that seem optimal

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

List of all continuous EMOs has no TRY blocks.

acheshkov opened this issue · comments

commented

I try to generate all continuous EMOs for the following code snippet:

public class InsertExecutor {
    protected int getPkValuesBySequence() {
        try {
            a = 1;
        } catch (SQLException ignore) {
        }
        
        if (a > 2) {
            a = b + 2;
            b = a - 2;
        }
    }
}

I get the following list of EMOs:

0th extraction opportunity:
    First statement: Statement expression on line 4
    Last statement: Statement expression on line 4
range: 
             a = 1; 
 -----
1th extraction opportunity:
    First statement: If statement on line 8
    Last statement: Statement expression on line 10
range: 
         if (a > 2) {
            a = b + 2;
            b = a - 2;
        } 
 -----
2th extraction opportunity:
    First statement: Statement expression on line 9
    Last statement: Statement expression on line 9
range: 
             a = b + 2; 
 -----
3th extraction opportunity:
    First statement: Statement expression on line 9
    Last statement: Statement expression on line 10
range: 
            a = b + 2;
            b = a - 2; 
 -----
4th extraction opportunity:
    First statement: Statement expression on line 10
    Last statement: Statement expression on line 10
range: 
             b = a - 2; 

Among all EMOs I expect to see:

try {
  a = 1;
} catch (SQLException ignore) {
}