View Source Credo.Check.Refactor.NegatedConditionsInUnless (Credo v1.7.0)
This check has a base priority of high
and works with any version of Elixir.
explanation
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?
check-specific-parameters
Check-Specific Parameters
There are no specific parameters for this check.
general-parameters
General Parameters
Like with all checks, general params can be applied.
Parameters can be configured via the .credo.exs
config file.