Credo.Check.Refactor.NegatedConditionsInUnless (Credo v1.5.0) View Source
This check has a base priority of high
and works with any version of Elixir.
Explanation
Unless blocks should avoid having a negated condition.
The code in this example ...
unless !allowed? do
proceed_as_planned()
end
... should be refactored to look like this:
if allowed? do
proceed_as_planned()
end
The reason for this is not a technical but a human one. It is pretty difficult to wrap your head around a block of code that is executed if a negated condition is NOT met. See what I mean?
Configuration parameters
There are no specific parameters for this check.
Like with all checks, general params can be applied.
Parameters can be configured via the .credo.exs
config file.