Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mehen.ophi.dev/llms.txt

Use this file to discover all available pages before exploring further.

The ABC metric is a size measure proposed by Jerry Fitzpatrick in 1997. It counts three types of syntactic features and reports them as a vector and as a magnitude.
LetterWhat it counts
AssignmentsVariable assignments (=, +=, −=, ++, −−, etc.).
BranchesCalls to other procedures (i.e., method/function invocations).
ConditionsConditional tests (if, case, when, ternary, exception catches, comparison
operators).
The vector <A, B, C> is reported alongside the magnitude |ABC| = sqrt(A² + B² + C²).

What mehen emits

KeyTypeDescription
abcfloatMagnitude sqrt(A² + B² + C²).
abc.assignmentsintTotal assignments in the space.
abc.assignments_minintMinimum across child spaces.
abc.assignments_maxintMaximum across child spaces.
abc.assignments_averagefloatAverage across child spaces.
abc.branchesintTotal branches.
abc.branches_min / _max / _averageAggregates.
abc.conditionsintTotal conditions.
abc.conditions_min / _max / _averageAggregates.

How to read it

There is no universal threshold, but Fitzpatrick’s original paper proposed:
MagnitudeInterpretation
0–10Tiny method; check whether it should be inlined.
10–20Normal method size.
20–40Large; consider refactoring.
40+Very large; refactor candidate.
The Ruby community adopted ABC widely via rubocop-rubycop/rubycritic, which uses <A, B, C> and a magnitude threshold of 17 by default for methods.

Per-language increments

Each language analyzer maps its statement and expression node kinds onto the three buckets. The canonical mapping:
  • Assignments: =, +=, −=, *=, /=, %=, <<=, >>=, &=, |=, ^=, prefix/postfix ++/−−, parameter default values where applicable.
  • Branches: function calls, method calls, constructors, super(...) calls, and dynamic dispatch.
  • Conditions: if, else if, case/when, ternary, && / ||, equality and ordering operators, exception handlers (catch, rescue, except).

References

See also