
A code quality audit is a review that measures how safely and cheaply a codebase can be changed. It looks at duplication, complexity, tests, builds, change history and who understands which parts, then reports where the risk concentrates and what to fix first.
It is narrower than a full codebase audit, which also covers architecture, data, security and the running system. It is wider than a code review audit of individual changes. If you are not sure which you need, start with what is a code audit.
- A code quality audit measures how safely and cheaply a codebase can be changed. It is about maintainability, not whether the software works today.
- Measure seven things: size, duplication, complexity, change hotspots, tests you can trust, build reproducibility, and how knowledge is spread across the team.
- Test coverage and a single debt ratio mislead more often than any other numbers. Report them as trends, never as a grade.
- Every measure in this article uses public tools your own team can run. What an audit adds is the judgment about which findings matter.
What does a code quality audit measure?
Quality here means one thing: will the next change be safe, and will it take as long as it should? Seven measures answer that question between them.
| Measure | The question it answers | Public tools | What it can't tell you |
|---|---|---|---|
| Size and inventory | How big is this, in what languages? | cloc, scc | How hard any of it is |
| Duplication | When we fix a bug, how many copies carry it? | jscpd, PMD CPD | Clones written in different words |
| Complexity | Which functions are hardest to reason about? | Lizard | Whether that function matters |
| Change hotspots | Where do defects and cost concentrate? | code-maat, git log | Anything, if there is no version history |
| Test reality | If we change this, will anything tell us we broke it? | The test suite itself | Whether the tests check the right things |
| Build reproducibility | Can a new engineer build this on day one? | A clean machine | Nothing: it builds or it doesn't |
| Knowledge concentration | How much of the code has one person who understands it? | git log, authorship by folder | Who understands, as opposed to who typed |
The last column matters as much as the tools. Each measure has a ceiling, and a good report states it next to the finding.
How do you measure maintainability in a code quality assessment?
Start with size, but don't stop there
Line counts by language give you the denominator for everything else. They say nothing about difficulty. A long stored procedure full of business rules can be harder to change than a large folder of generated markup.
Find duplication, then trace it
Clone detection finds copy-pasted blocks. The useful step comes after: checking whether the copies have drifted apart. Two copies that started identical and now differ slightly are where bugs get fixed in one place and not the other.
Measure complexity where it counts
Cyclomatic complexity counts the paths through a function. On its own it produces a long list of complicated functions, most of which nobody touches. It becomes useful when combined with change history.
Rank by change hotspots
Take how often each file changes from version history, multiply by its complexity, and sort. Files that change constantly and are hard to reason about are where defects and cost concentrate. This one measure usually tells you more than the rest combined, because it ranks the problems instead of listing them. It needs version history. If the code lives on a file share, say so, and treat the result as much weaker.
Test whether the tests can be trusted
Ask four questions. Does a suite exist? Does it run today on a clean machine? What does it actually check? How many tests are skipped or fail at random and get ignored? The best single question is the one you ask the team: would you ship on a green build alone?
Try to build it from scratch
From a clean environment, using only what is checked in, try to build and run the system. Record every step that needed someone's memory or a file that wasn't in source control. This result is binary, and it is one of the most persuasive lines in any report.
Map who can change what
Look at who has changed each folder, and cross-check against who still works there. Modules with a single living author are a risk with a date attached. Commits measure who typed, not who understands, so confirm with the team.
Which code quality metrics mislead?
Two numbers cause most of the trouble in a code quality audit.
Test coverage percentage
Coverage tells you which lines ran during the tests. It doesn't tell you whether the tests checked anything. A suite can run most of the code and assert almost nothing about the business rules, and the coverage figure will still look good. Report coverage for the critical paths, alongside what the tests actually assert, and never as a single headline number.
A single debt ratio or letter grade
Tools that grade maintainability usually divide estimated fix effort by estimated build cost. The result scales with codebase size and rests on assumptions you can change in a settings screen. It is good for tracking a trend over time. It is poor as a price tag or a pass mark. We explain the calculation in how to measure technical debt.
Code quality audit vs code review audit
A code review audit looks back over recent pull requests to check whether reviews are happening and whether they catch problems. A code quality audit looks at the state of the code itself.
| Code review audit | Code quality audit | |
|---|---|---|
| Looks at | The review process | The codebase |
| Question | Are our reviews working? | Can this code be changed safely? |
| Evidence | Pull request history, comments, approval times | Source, version history, test runs, builds |
| Typical finding | Large changes approved with no comments | A billing module that only one person has touched |
Both are useful. The code quality audit is the one that tells you what you already own.
Is there a standard for code quality?
The international software product quality model, ISO/IEC 25010, defines characteristics such as maintainability and reliability. Audit findings can be measured against it. No codebase is "certified" to it, because it is a quality model, not a certification scheme. Be wary of any report that implies otherwise.
What should a code quality audit report include?
Rank the findings by risk to the business, starting from the change hotspots. Give each one its evidence: the file, the measure, the test run. Give a rough size for the fix and the order of work. Open with a one-page summary in plain language, and state the ceilings: what each measure could not see. Many findings will look like familiar technical debt examples.
For the full list of areas beyond code quality, including dependencies, security and operations, use our code audit checklist.
What the 30-day assessment covers
Code quality is a large part of our 30-day assessment, but not all of it. The assessment is fixed in scope, at a price agreed before we start. We read the system at rest in week one, including every measure in the table above, and while it runs in week two. Week three is writing and checking findings with your team, and in week four we walk the pack through with the people who decide.
The tools we name are public, so your team can run them and check our numbers. What you are paying for is the reading that turns their output into a short, ranked list. Your own team can act on the report, or we can do the work as a separate project. Either way, the report stands on its own.
Pick a time to talk about the codebase you're worried about.
