Examples of errors detected by the V6004 diagnostic


V6004. The 'then' statement is equivalent to the 'else' statement.


SonarQube

V6004 [CWE-691] The 'then' statement is equivalent to the 'else' statement. Check lines: 76, 78. OneIssuePerLineSensor.java 76


public static final String EFFORT_TO_FIX_PROPERTY =
  "sonar.oneIssuePerLine.effortToFix";
public static final String FORCE_SEVERITY_PROPERTY =
  "sonar.oneIssuePerLine.forceSeverity";

private void createIssues(InputFile file, SensorContext context, String repo) {
 ....
 if (context.getSonarQubeVersion().isGreaterThanOrEqual(Version.create(5, 5))) {
   newIssue.gap(context.settings().getDouble(EFFORT_TO_FIX_PROPERTY));
 } else {
   newIssue.gap(context.settings().getDouble(EFFORT_TO_FIX_PROPERTY));
 }
 ....
}


Bugs Found

Checked Projects
346
Collected Errors
13 188