View Source Credo.Check.Refactor.ABCSize (Credo v1.7.0)
This check has a base priority of 0
and works with any version of Elixir.
explanation
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.
check-specific-parameters
Check-Specific Parameters
Use the following parameters to configure this check:
max_size
:max_size
The maximum ABC size a function should have.
This parameter defaults to 30
.
excluded_functions
:excluded_functions
All functions listed will be ignored.
This parameter defaults to []
.
general-parameters
General Parameters
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