Credo.Check.Refactor.ABCSize (Credo v1.5.0) View Source
This check has a base priority of 0
and works with any version of Elixir.
Explanation
The ABC size describes a metric based on assignments, branches and conditions.
A high ABC size is a hint that a function might be doing "more" than it should.
As always: Take any metric with a grain of salt. Since this one was originally introduced for C, C++ and Java, we still have to see whether or not this can be a useful metric in a declarative language like Elixir.
Configuration parameters
Use the following parameters to configure this check:
max_size
: The maximum ABC size a function should have.Defaults to
30
excluded_functions
: All functions listed will be ignored.Defaults to
[]
Like with all checks, general params can be applied.
Parameters can be configured via the .credo.exs
config file.
Link to this section Summary
Functions
Returns the ABC size for the block inside the given AST, which is expected to represent a function or macro definition.
Link to this section Functions
Returns the ABC size for the block inside the given AST, which is expected to represent a function or macro definition.
iex> {:def, [line: 1],
...> [
...> {:first_fun, [line: 1], nil},
...> [do: {:=, [line: 2], [{:x, [line: 2], nil}, 1]}]
...> ]
...> } |> Credo.Check.Refactor.ABCSize.abc_size
1.0