Skip to content

G-4270: Avoid comparing boolean values to boolean literals.

Minor

Maintainability, Testability

Reason

It is more readable to simply use the boolean value as a condition itself, rather than use a comparison condition comparing the boolean value to the literals true or false.

Example (bad)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
declare
   co_string  constant types_up.text := '42';
   l_is_valid boolean;
begin
   l_is_valid := my_package.is_valid_number(co_string);
   if l_is_valid = true then
      my_package.convert_number(l_string);
   end if;
end;
/

Example (good)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
declare
   co_string  constant types_up.text := '42';
   l_is_valid boolean;
begin
   l_is_valid := my_package.is_valid_number(co_string);
   if l_is_valid then
      my_package.convert_number(l_string);
   end if;
end;
/