31 lines
830 B
Plaintext
31 lines
830 B
Plaintext
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;
|
|
----
|
|
|
|
include::../exceptions.adoc[]
|
|
|
|
include::../see.adoc[]
|