OptimumCredo.Check.Readability.TypeParenthesesConsistency (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

Keep type syntax consistent: by default definitions have no parentheses and references do.

Bad

@type t() :: %__MODULE__{}
@spec run(map) :: String.t

Good

@type t :: %__MODULE__{}
@spec run(map()) :: String.t()

Both styles are configurable. Bare references are only detected for built-in types and types defined in the same file, because type variables look identical.

Check-Specific Parameters

Use the following parameters to configure this check:

:definition_style

:bare (@type t ::) or :parens (@type t() ::).

This parameter defaults to :bare.

:reference_style

:parens (map()) or :bare (map).

This parameter defaults to :parens.

General Parameters

Like with all checks, general params can be applied.

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