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

org.sonar.css.checks.l10n.scss.branch-same-implementation.html Maven / Gradle / Ivy

There is a newer version: 4.13
Show newest version

Having two branches in the same @if ... @else if ... @else 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 $x == 0 {
  do-something();
} @else if $x == 1 {
  do-something-different();
} @else {
  do-something();   /* Noncompliant: Same implementation as in the @if block */
}

Compliant Solution

@if $x == 1 {
  do-something-different();
} @else {
  do-something();
}

OR

@if $x == 0 {
  do-something();
} @else if $x == 1 {
  do-something-different();
} @else {
  do-something-else();
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy