View Source Credo.Check.Warning.SpecWithStruct (Credo v1.7.0)
This check has a base priority of normal
and works with any version of Elixir.
explanation
Explanation
Structs create compile-time dependencies between modules. Using a struct in a spec will cause the module to be recompiled whenever the struct's module changes.
It is preferable to define and use MyModule.t()
instead of %MyModule{}
in specs.
Example:
# preferred
@spec a_function(MyModule.t()) :: any
# NOT preferred
@spec a_function(%MyModule{}) :: any
check-specific-parameters
Check-Specific Parameters
There are no specific parameters for this check.
general-parameters
General Parameters
Like with all checks, general params can be applied.
Parameters can be configured via the .credo.exs
config file.