Credence.Rule.NoIsPrefix
(credence v0.2.0)
Copy Markdown
Style rule: Detects functions named with an is_ prefix that are not
guard-safe BIFs.
In Elixir, predicate functions use a trailing ? by convention (e.g.
valid?/1, palindrome?/1). The is_ prefix is reserved for guard-safe
type checks from Erlang (is_list/1, is_integer/1, etc.). User-defined
functions named is_foo look like guards but aren't usable in guards,
which misleads readers.
Bad
def is_valid_palindrome(s), do: ...
defp is_empty(list), do: ...Good
def valid_palindrome?(s), do: ...
defp empty?(list), do: ...