Programming: Code Complexity Metrics

From wikinotes

Metrics to help you identify parts of your codebase that might be difficult to modify.
Also known as Programming Complexity.

Documentation

wikipedia https://en.wikipedia.org/wiki/Programming_complexity

SLOC (source lines of code)

Literally, the number of lines of code in your application.

Cyclomatic Complexity

wikipedia https://en.wikipedia.org/wiki/Cyclomatic_complexity
ruby lib https://github.com/soutaro/cycromatic

Maps the tree of all possible permutations of conditionals in your code.

# where a connected-component is a separate system (ex. library call)
edges - nodes + (2 * connected-components)
1-10: simple
11-20: complex
20-50: highly complex
50+:   impossibly complex

ABC (Assignments, Branches, Conditions)

wikipedia https://en.wikipedia.org/wiki/ABC_Software_Metric
ruby lib https://github.com/seattlerb/flog

Essentially, add 1 point for every assignment, conditional, and function call.
It builds an Abstract Syntax Tree of your code, then walks it and tallies the score.