G-1080
🆓Error
Avoid using the same expression on both sides of a relational comparison operator or a logical operator.
Reason
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
.
Example
Non-Compliant Example
begin select emp.first_name ,emp.last_name ,emp.salary ,emp.hire_date from employees emp where emp.salary > 3000 or emp.salary > 3000 order by emp.last_name,emp.first_name; end; /
Issues
Line | Column | Message |
---|---|---|
7 | 11 |
★★★★★
Compliant Solution -
begin select emp.first_name ,emp.last_name ,emp.salary ,emp.hire_date from employees emp where emp.salary > 3000 order by emp.last_name,emp.first_name; end; /
Parameters
Use parameters to customize the rule to your needs.
Parameter | Description | Default Value |
---|---|---|
IgnoreConstantConditions | Comma-separated list of conditions (without whitespace) that are either always true or always false. | 1=1, 1!=1, 1<>1, 1~=1, 1^=1 |
References
- same as Trivadis G-1080
- same as plsqlopen:IdenticalExpression
- same as plsql:S1764