Code Quality Metrics Vocabulary

Tip: Quality metrics only help if they drive action — a quality gate that nobody fixes is worse than no gate at all.

0 / 5 completed

Exercise 1 of 5

The tech lead reviews a PR: 'This function has cyclomatic complexity of 15. Every if, else if, for, while, and logical operator adds 1. We cap it at 10 — above that it needs 15 test cases just for branch coverage.'

What does cyclomatic complexity measure?

Exercise 2 of 5

The QA lead explains: 'We have 78% line coverage but low branch coverage. Line coverage hits both sides of an if block if you test x=1, but the else branch is never executed — branch coverage catches that gap.'

What is the key difference between line coverage and branch coverage?

Exercise 3 of 5

The architect says: 'We want high cohesion and low coupling. High cohesion means a class does one thing well. Low coupling means modules don't depend on each other's internals — changes don't cascade.'

Why is high cohesion desirable?

Exercise 4 of 5

The senior dev explains to the PM: 'Prudent deliberate debt — we know we are cutting corners, we'll fix it after launch. Reckless inadvertent debt — we wrote bad code without knowing there was a better approach.'

What does the technical debt quadrant (Martin Fowler) help teams do?

Exercise 5 of 5

The team's SonarQube build fails: 'Quality gate failed — new code coverage 62%, below the 80% threshold. Three new critical code smells. Maintainability rating C. No merge until these pass.'

What is a quality gate in a CI/CD pipeline?