3

How can i find the empty try catch blocks?

Using the Copy existing template... I found the structural search for try catch:

try {
  $TryStatement$;
} catch($ExceptionType$ $Exception$) {
  $CatchStatement$;
}

I want to enhance it so that it does only find try catches with empty catch blocks

It should find:

 try {
        assertTrue(output.validate());
    } catch (Exception e) {
        //TODO something
    }

or

    try {
        assertTrue(output.validate());
    } catch (Exception e) {

    }

or

try {
        assertTrue(output.validate());
    } catch (Exception e) {}

However not:

 try {
        assertTrue(output.validate());
    } catch (Exception e) {
        e.printStackTrace();
    }

Right now it obviously finds both since there's no differentiation betweens. How can I add this extra check?

user1167253
  • 813
  • 1
  • 11
  • 27

1 Answers1

1

Use the template you have found and on CatchStatement variable set Min count and Max count to 0.

jan_bar
  • 71
  • 8