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

Common types in @spec declarations should be extracted to module-level semantic type aliases for better readability, maintainability and consistency.

Examples

Bad:

@spec show(Plug.Conn.t(), map()) :: Plug.Conn.t()
@spec index(Plug.Conn.t(), map()) :: Plug.Conn.t()

Good:

@type conn :: Plug.Conn.t()
@type params :: map()

@spec show(conn(), params()) :: conn()
@spec index(conn(), params()) :: conn()

This provides semantic meaning and ensures consistency across all modules.

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.