Almost half of React's code is tests: what a SLOC counter shows that GitHub hides
GitHub's repository sidebar shows language percentages. It never shows line counts. That always bothered me: is this dependency I'm about to adopt a tidy 2,000 lines or a 200,000-line monolith? The language bar says JavaScript 58%, TypeScript 42%, and nothing about how much of anything there is. So I built OctoCounts . Paste any public GitHub repository URL and it downloads the source archive,…
GitHub's repository sidebar displays language percentages but never line counts, which raised questions about the size of a dependency one is about to adopt. To address this, a tool called OctoCounts was created to provide line counts, files, total lines, code, comments, blanks, and per-language totals for any public GitHub repository.
By pasting a public GitHub repository URL, the tool downloads the source archive, runs tokei, and gives detailed information about the files and their contents. When applied to the React codebase, it was found that almost half of React's code is made up of tests, with the number collapsing to approximately 364,248 code lines when tests are excluded.
This highlights that the majority of React's code is not actively used but rather serves as tests. Similar findings were observed in other repositories like Vite, where tests account for over a quarter of the code. OctoCounts ensures that any SLOC (Source Lines of Code) comparison is valid by pinning reports to specific commit SHA and configuration, making the data reliable and accurate for comparisons.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.