Skip to content

Commit 16d67a4

Browse files
committed
Fix #44 - Created rule G-4260: Avoid inverting boolean conditions.
1 parent 865aac4 commit 16d67a4

File tree

1 file changed

+34
-0
lines changed
  • docs/4-language-usage/4-control-structures/2-case-if-decode-nvl-nvl2-coalesce

1 file changed

+34
-0
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# G-4260: Avoid inverting boolean conditions.
2+
3+
!!! tip "Minor"
4+
Maintainability, Testability
5+
6+
## Reason
7+
8+
It is more readable to use the opposite comparison operator instead of inverting the comparison with `not`.
9+
10+
## Example (bad)
11+
12+
``` sql
13+
declare
14+
l_color varchar2(7 char);
15+
begin
16+
if not l_color != constants_up.co_red then
17+
my_package.do_red();
18+
end if;
19+
end;
20+
/
21+
```
22+
23+
## Example (good)
24+
25+
``` sql
26+
declare
27+
l_color types_up.color_code_type;
28+
begin
29+
if l_color = constants_up.co_red then
30+
my_package.do_red();
31+
end if;
32+
end;
33+
/
34+
```

0 commit comments

Comments
 (0)