Rule, reporting ==
when equivalent case of
exists
forbid : ForbiddenLocation -> Review.Rule.Rule
Reports when ==
is used but there's there is an equivalent case of
available.
config =
[ EqualsCaseable.forbid EqualsCaseable.InIf
]
Where the given ForbiddenLocation
can be either
if
" → InIf
Everywhere
a =
if list == [] then
"empty"
else
"filled"
a =
case list of
[] ->
"empty"
_ :: _ ->
"filled"
Configuration option for EqualsCaseable.forbid
.
Can be either
if
" → InIf
reported
a =
if list == [] then
"empty"
else
"filled"
not reported
a =
case list of
[] ->
"empty"
_ :: _ ->
"filled"
Everywhere
reported
a =
if list == [] then
"empty"
else
"filled"
b =
users |> List.filter (\u -> u.role == Moderator)
not reported
a =
users
|> List.filter
(\u ->
case u.role of
Moderator ->
True
_ ->
False
)
If (\a -> a.something == Variant)
etc is a very common pattern
in your code base, you'll have an easier time
converting all the if
s first.
To get the discussed benefits like "Now the compiler will tell me all the places I need to make a new decision", you do need to refactor all these equality checks.
Your goal should be EqualsCaseable.forbid Everywhere