You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is because these expressions evaluate to true or false, so you could get the same result by using either the variable directly or negating the variable.
Examples
-modulebad.
-export [my_fun/2].
my_fun(P1, P2) ->casedo:something(P1) ==falseorelsedo:something(P2) ==falseoftrue -> "There is a false";
false -> "All true"end.
-modulegood.
-export [my_fun/2].
my_fun(P1, P2) ->case (notdo:something(P1)) orelse (notdo:something(P2)) oftrue -> "There is a false";
false -> "All true"end.
%% … or even …my_fun(P1, P2) ->casedo:something(P1) andalsodo:something(P2) oftrue -> "All true";
false -> "There is a false"end.
Avoid Comparison to Boolean
Brief Description
A rule that disallows comparison to booleans.
Should be on by default?
YES
Reasoning
This is because these expressions evaluate to
true
orfalse
, so you could get the same result by using either the variable directly or negating the variable.Examples
Origin (#281)
Inspired by the
ComparisonToBoolean
rule from Dogma.The text was updated successfully, but these errors were encountered: