Reliability: same result when applied multiple times ▸ Scaling: there’s a scale for measuring the results ▸ Comparability: measurements can be compared
Usefulness and Validity) ▸ lines of »real« code ▸ lines with comments (overall vs. single-line vs. block) ▸ lines mixed up with source and comments ▸ empty lines
calculated by developing a control flow graph of the code. It’s a quantitative measure of the number of linearly independent paths through a program’s source code. !
at least one edge which hasn’t been traversed before in any other paths. Control flow depicts a program as a graph which consists of nodes and edges. !
= structured and well written code, low risk ▸ 11–20 = complex code, moderate risk ▸ 21–50 = very complex code, high risk ▸ >50 = not testable at all, extreme risk
counting the number of paths through a program (= the amount of potential outcomes given certain conditions). Rule of thumb: the lower a program’s cyclomatic complexity, the lower is the risk to modify it and the easier it is to understand.
about the number of decisions a browser has to make before it can or can’t style something. Rule of thumb: Every part of a CSS selector is an IF statement. The more IF statements in our selectors, the greater is the selector’s cyclomatic complexity.
div.image-buttons-panel a span.button.btn-video-text { // Do something } ▸ Subject (what we actually care about): .btn-video-text ▸ Condition (needless complexity): .column-wide .asset- list-box-hp-special ul li div.video-pic div.image-buttons-panel a span.button
of application. There are no universal standards. Define your own set of metrics and their limits for your project. Metrics are no replacement for revisions, tests, or verifications.