OptimumCredo.Check.Readability.DescribeFunctionArity (OptimumCredo v0.5.0)

View Source

Basics

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

Name unit-test describe blocks after the function and arity, and web tests after the route.

Bad: describe "registering a user" do Good: describe "register_user/1" do Good (web tests): describe "/register" do

Use allowed_patterns for deliberate groupings such as "^when ".

Check-Specific Parameters

Use the following parameters to configure this check:

:describe_pattern

Regex source a unit-test describe name must match.

This parameter defaults to "^\\w+[?!]?/\\d+( [^\\n]+)?$".

:web_describe_pattern

Additional regex source accepted in web-test paths.

This parameter defaults to "^([A-Z]+ )?/".

:web_paths

Path fragments identifying web tests.

This parameter defaults to ["_web/"].

:unit_paths

If non-empty, restrict the check to files matching these fragments.

This parameter defaults to [].

:ignore_paths

Path fragments to skip.

This parameter defaults to ["test/support/", "/features/", "/integration/"].

:allowed_patterns

Regex sources of describe names that are always accepted.

This parameter defaults to ["^on_mount :\\w+$"].

General Parameters

Like with all checks, general params can be applied.

Parameters can be configured via the .credo.exs config file.