Using the same value on either side of a binary operator is almost always a mistake. In the case of logical operators, it is either a copy/paste
error and therefore a bug, or it is simply wasted code, and should be simplified.
This rule ignores operators +
, *
and ||
, and expressions: 1=1
, 1<>1
,
1!=1
, 1~=1
and 1^=1
.
Noncompliant code example
SELECT code
FROM Person
WHERE first_name IS NULL OR first_name IS NULL; -- Noncompliant
SELECT * FROM Users
INNER JOIN Clients ON Clients.id = Clients.id; -- Noncompliant
Compliant solution
SELECT code
FROM Person
WHERE first_name IS NULL OR last_name IS NULL;
SELECT * FROM Users
INNER JOIN Clients ON Clients.id = Users.id;
Exceptions
This rule ignores *
, +
, and =
.