Reports if statements in which common parts can be extracted from the branches.

These common parts are independent from the condition and make if statements harder to understand.

Example:


  if (x > 12) {
    doSomethingBefore();
    doSomethingDifferent1();
    doSomethingAfter();
  } else {
    doSomethingBefore();
    doSomethingDifferent2();
    doSomethingAfter();
  }

After the quick-fix is applied:


  doSomethingBefore();
  if (x > 12) {
    doSomethingDifferent1();
  } else {
    doSomethingDifferent2();
  }
  doSomethingAfter();

Updated in 2018.1