Credo v1.5.0-rc.2 Credo.Check.Readability.PredicateFunctionNames View Source

This check has a base priority of high and works with any version of Elixir.

Explanation

Predicate functions/macros should be named accordingly:

  • For functions, they should end in a question mark.

    # preferred

    defp user?(cookie) do end

    defp has_attachment?(mail) do end

    # NOT preferred

    defp is_user?(cookie) do end

    defp is_user(cookie) do end

  • For guard-safe macros they should have the prefix is_ and not end in a question mark.

    # preferred

    defmacro is_user(cookie) do end

    # NOT preferred

    defmacro is_user?(cookie) do end

    defmacro user?(cookie) do end

Like all Readability issues, this one is not a technical concern. But you can improve the odds of others reading and liking your code by making it easier to follow.

Configuration parameters

There are no parameters for this check.

Link to this section Summary

Link to this section Functions

Link to this function

do_run_on_source_file(exec, source_file, params)

View Source