Skip to content

New Rule: no comparison of boolean variables #45

Closed
@silviomarghitola

Description

@silviomarghitola

Language Usage / Control Structures / CASE ...
Avoid comparing boolean variables or colums with TRUE or FALSE

from SonarQube

Boolean literals should not be redundant

Redundant Boolean literals should be removed from expressions to improve readability.

Noncompliant Code Example

DECLARE
  foo BOOLEAN := TRUE;
BEGIN
  IF foo = FALSE THEN
    DBMS_OUTPUT.PUT_LINE('foo = false!');
  ELSIF foo = TRUE THEN
    DBMS_OUTPUT.PUT_LINE('foo = true!');
  END IF;
END;

Compliant Solution

DECLARE
  foo BOOLEAN := TRUE;
BEGIN
  IF NOT foo THEN
    DBMS_OUTPUT.PUT_LINE('foo = false!');
  ELSIF foo THEN
    DBMS_OUTPUT.PUT_LINE('foo = true!');
  END IF;
END;

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions