All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.sonar.l10n.plsqlopen.rules.plsql.SameBranch.html Maven / Gradle / Ivy

The newest version!

Having two branches in the same if structure with the same implementation is at best duplicate code, and at worst a coding error. If the same logic is truly needed for both instances, then they should be combined.

Noncompliant Code Example

IF var BETWEEN 0 AND 10 THEN
  do_the_thing();
ELSIF var BETWEEN 10 AND 20 THEN
  do_the_thing(); -- Noncompliant; duplicates first condition
ELSIF var BETWEEN 20 AND 50 THEN
  do_the_another_thing();
ELSE
  do_the_rest()
END IF;

Compliant Solution

IF var BETWEEN 0 AND 10 THEN
  do_the_thing();
ELSIF var BETWEEN 10 AND 20 THEN
  do_the_second_thing();
ELSIF var BETWEEN 20 AND 50 THEN
  do_the_another_thing();
ELSE
  do_the_rest()
END IF;




© 2015 - 2024 Weber Informatics LLC | Privacy Policy