Codebase stats are usually a vanity metric. The one version of them I find useful is the distribution: not how many lines there are, but how they are spread, because that is what decides whether a change means reading one file or six. I measured Nakodo, which is 582 TypeScript files and 72,683 lines, written by one person over about a year.
Files
| Files | Lines | Median | Mean | p90 | Max | |
|---|---|---|---|---|---|---|
| Everything | 582 | 72,683 | 77 | 125 | 242 | 1,372 |
| Not tests | 520 | 68,546 | 80 | 132 | 265 | 1,372 |
| Tests | 62 | 4,137 | 60 | 67 | 134 | 206 |
The histogram of the 520 non-test files is almost flat up to 200 lines and then falls off a cliff:
1-25 lines 92 files 26-50 lines 105 51-100 lines 105 101-200 lines 107 201-400 lines 88 401-800 lines 17 800+ lines 6 Six files over 800 lines, 23 over 400, and 191 under 50. Where the mass sits:
top 5 files = 8.1% of all non-test lines top 10 files = 13.3% top 25 files = 24.5% top 50 files = 36.1% A quarter of the codebase is in 25 files out of 520, and the single largest, the campaigns Server Actions module at 1,372 lines, is 2.0% of everything on its own.
By directory the split is not what I would have guessed:
| Directory | Files | Lines | Median file |
|---|---|---|---|
lib | 171 | 24,148 | 96 |
app | 182 | 22,505 | 53 |
content | 77 | 13,660 | 194 |
components | 82 | 6,727 | 48 |
db | 2 | 1,297 | 648 |
content is the surprise: 13,660 lines, 20% of the codebase, is the text of the guides, the glossary, the blog and the niche and audience pages, written as typed data rather than markdown. Its median file is the largest of any directory except db, because a 2,000-word guide is a 194-line object. That is a fifth of the repo that is prose, and it means the line count of this project overstates how much code there is by about a fifth.
db is two files: the schema at 1,267 lines and the client. One of them is the second-largest file in the repo.
Functions
Walking each file with a regex for function and arrow declarations and brace-matching the body gives 1,723 functions:
median 5 lines mean 10.3 p90 24 max 443 701 functions are 3 lines or shorter 51 are over 50 lines 11 are over 100 A median of five lines against a median file of 80 means a typical file is a dozen small functions, which matches how the code reads: lots of named predicates and formatters, few long procedures. The 701 functions of three lines or fewer are mostly that: const daysAgo = (n: number) => new Date(Date.now() - n * DAY_MS).
All eleven functions over 100 lines, with no editing of the list:
443 component DetailsEditor campaigns/[id]/outreach/details/editor.tsx 341 component RepliesEditor campaigns/[id]/outreach/replies/editor.tsx 284 component ProposalEditor campaigns/[id]/outreach/proposal/editor.tsx 223 logic runMaintenance lib/pipeline/maintenance.ts 223 logic daysAgo lib/pipeline/maintenance.ts 145 logic addAngles lib/pipeline/angles.ts 132 logic sendNoticeAction admin/mailing/actions.ts 120 logic addPlaces lib/pipeline/places.ts 111 component Anatomy (marketing)/page.tsx 104 logic POST api/email/inbound/route.ts 101 logic handleReply lib/outreach/reply.ts Four of the eleven are React components whose bodies are mostly JSX, which is a different kind of long. Three are pipeline steps that read as a sequence of database operations with comments between them, and those are the three I would look at first.
Where the measurement is wrong
daysAgo is one line. It appears as 223 because my brace matcher starts at the first { after the declaration, and an arrow function returning an expression has no block, so the match ran on into the next function's body. Two of the eleven entries above are therefore one function reported twice, and runMaintenance is the real 223-line offender.
I am leaving the mistake in the post because it is the normal failure mode of this kind of measurement, and because it is instructive: the error inflates exactly the thing you are looking for, long functions, so a lazy reading of the output would have sent me to refactor a one-line date helper. If you run this on your own repo, check the top of the list by hand before you believe it. A real parser (TypeScript's own, or ts-morph) gets this right; a 15-line script does not.
The 120-column rule
This repo has no Prettier, no ESLint formatting rules and no editor config. It is hand-formatted to roughly 120 columns, which is a rule that exists only in my head, so it is worth checking against the file system:
lines over 120 characters: 3,789 of 68,546 (5.5%) files containing at least one: 339 of 520 files with 3 or fewer: 157 worst file: src/content/method.ts, 56 lines, longest 786 characters The violations are not where style rules usually find them. The top of that list is content files, where a single string holds a paragraph of a page, and the editors, where a className with six responsive variants runs long. Actual logic almost never crosses 120 columns, because logic wraps naturally at that width and prose does not.
So the rule holds for code and is routinely broken by data, which is the correct outcome and not one a formatter would have given me: Prettier would have rewrapped the paragraphs and left the whole repo looking like a diff of itself.
What I take from this
- The distribution is healthier than the maximum suggests. One 1,372-line file is a known chore, but 191 files under 50 lines and a median function of 5 is the shape I wanted and I had not checked that it was true.
- A fifth of the "codebase" is page copy. Any metric anyone quotes about this repo, line counts, test coverage, comment density, is diluted by 13,660 lines of English, and I should be measuring
src/contentseparately from now on. - The three long pipeline functions are the real debt, not the large editors. A 443-line component is one screen's worth of JSX; a 223-line function that updates four tables in order is where a bug hides.
The product those lines add up to is at nakodo.app, and the 13,660 lines of content directory are readable as 22 guides and a glossary if you want to see what a 194-line TypeScript object looks like once it is a page.




