OptimumCredo.Check.Readability.VerboseAssertions (OptimumCredo v0.5.0)
View SourceBasics
This check is disabled by default.
Learn how to enable it via .credo.exs.
This check has a base priority of low and works with any version of Elixir.
Explanation
Assertion patterns should use explicit is_nil/1 predicates instead
of equality comparisons with nil.
Examples
Bad:
assert drop.id != nil
assert user.name == nil
refute item.id != nil
refute status == nilGood:
refute is_nil(drop.id)
assert is_nil(user.name)
assert is_nil(item.id)
refute is_nil(status)Bare assert value and refute value also reject or accept false, respectively,
so they are not equivalent to nil comparisons. Keep the nil predicate explicit.
Check-Specific Parameters
There are no specific parameters for this check.
General Parameters
Like with all checks, general params can be applied.
Parameters can be configured via the .credo.exs config file.