View Source Credo.Check.Refactor.NegatedConditionsInUnless (Credo v1.7.5)
This check is enabled by default.
Learn how to disable it via
This check has a base priority of
high and works with any version of Elixir.
Unless blocks should avoid having a negated condition.
The code in this example ...
unless !allowed? do
... should be refactored to look like this:
if allowed? do
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?
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.