typescript:S1125: Mistake in Noncompliant Code Example

Must-share information (formatted with Markdown):

  • which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension)
    Version 10.2.1 (build 78527
  • how is SonarQube deployed: zip, Docker, Helm
    Docker

Error is also Present in Sonar lint

Rule Description:
This rule also reports on redundant boolean operations.

if (someValue === true) { /* ... */ } // Noncompliant: Redundant comparison
if (someBooleanValue !== true) { /* ... */ } // Noncompliant: Redundant comparison
if (booleanMethod() || false) { /* ... */ }  // Noncompliant: Redundant OR
doSomething(!false); // Noncompliant: Redundant negation

Remove redundant boolean literals to improve readability.

if (someValue) { /* ... */ }
if (!someBooleanValue) { /* ... */ }
if (booleanMethod()) { /* ... */ }
doSomething(true);

Mistake: The rule itselve does not apply to someValue === true it only aplyes to someValue == true, the rule is correkt the desktiption is not

2 Likes

Hello @J_Velz ,

Thank you very much for reporting this. You are absolutely correct - I am fixing the rule description right now.

Done - Modify S1125: Remove strict comparison operators for javascript (#3336) · SonarSource/rspec@b8751a4 · GitHub

2 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.