Fifteen ways a static analyser lies to you

Every false finding my codebase reader produced on requests, flask, express, cobra, ripgrep and a real in-house monorepo — and what each one actually was.

4 December 2026

Dead-code and dependency tools all fail the same way. You run one on a repository you know, it tells you eleven files are unused, you check three, all three are alive, and you never open it again. The tool was not wrong about static reachability. It was wrong about what reachability means in a real project.

I spent a day pointing one at six codebases in four languages and fixing every answer that was not true. Here is the whole list, because the failures are more instructive than the successes — and because every one of them is a thing your current tool is probably still doing.

1. It reads files the project does not have

First run on a repository with generated test fixtures: 74 seconds, 549,826 files. The data a test writes is not source, and it is not committed. Walking the directory tree is both slower and wrong.

git ls-files -z

0.02 seconds, 67 files, and .gitignore is honoured for free because git already did that work. If the project is a git checkout, its own file list is the right answer.

2. It looks for the manifest in the wrong place

A monorepo with backend/pyproject.toml and frontend/package.json and nothing at the root. Result: every single import reported as an undeclared dependency — about 130 confident findings, all noise. Looking one level down fixes it, and it is also where the real commands live: the report had been leading with 33 stray scripts while cd frontend && npm run dev went unmentioned.

3. It calls framework-loaded code dead

Alembic runs every file in versions/. Django loads migrations/. pytest collects conftest.py. Nothing imports any of them, and all of them run. That was 248 false findings on one repository.

4. It calls your config files dead

vite.config.ts, eslint.config.js, everything in scripts/. Run by a tool, never imported. Same for anything with a shebang.

5. It resolves relative imports with the wrong language's rules

In Python, ..mod means two package levels up. In JavaScript, ../lib/api is path arithmetic. Treat them the same and '../lib/api' resolves against the filesystem root and silently disappears — so lib/api.ts, imported by half the application, lands in the dead-code list.

The dangerous bugs in this class are the silent ones. A resolver that throws gets fixed. A resolver that returns None produces a confident, wrong, plausible-looking report.

6. It does not know what a bundler does

const found = import.meta.glob<{ default: ComponentType }>('./*.tsx')

Nine lazily registered widgets, every one reported unused. Two separate problems: the pattern has to survive the TypeScript generic between the name and the call, and the glob has to be expanded and matched against real paths. Both are doable. Pretending the files are dead is not.

7. It stays silent about what it cannot see

When the target is a variable — importlib.import_module(name), a dynamic import() — no static reader can know what is loaded. The honest move is to resolve the literal cases, count the rest, and print a warning on the dead-code section saying it cannot be trusted in this repository. A tool that knows the limits of its own method is worth more than one that is confidently wrong.

8. It misses the commonest import shape in Python

from . import gitinfo

The module name is in the alias list, not in node.module. Drop it and every module imported that way looks dead. I found this by running the tool on itself.

9. It counts committed build output as source

A dist-prev/ folder someone committed: fifteen hashed asset bundles in the dead-code list, and the line count inflated by a few thousand lines of minified JavaScript.

10. It does not know what ships with the runtime

node:path is a Node builtin. setuptools is the build system. cStringIO is Python 2. None of them belong in a missing-dependency list.

11. It does not understand try: import

try:
    import simplejson as json
    has_simplejson = True
except ImportError:
    import json

if has_simplejson:
    from simplejson import JSONDecodeError

That is from requests. The author has plainly handled the package being absent. Calling it a missing dependency is the tool failing to read Python. Note the second import, outside the try — which is why "every import must be guarded" is the wrong rule, and "handled anywhere means optional" is the right one.

12. It cannot tell a dev dependency from a broken install

flask imports docutils in docs/conf.py and pytest in its tests. Neither will break an install. Mixed into one list they are noise; on their own line — "missing, but only for tests, docs or examples" — they are a real, small, fixable finding.

13. It raises test fixtures as leaked credentials

Four private keys in requests, all under tests/certs/, all committed on purpose. Worth listing. Not worth putting at the top of a report as if production had leaked.

14. It judges languages it never parsed

Point a Python/JavaScript import graph at a Go and Rust repository and you get "0% test-reachable, 2 dead files". Both statements are fabrications about files the tool never read. The fix is to exclude them and say so in the report.

And one that costs money

On a --filter=blob:none partial clone, git log --numstat needs file contents, so git quietly starts fetching every missing blob. My run went past two minutes before I killed it. A tool that claims to only read your repository must detect that and decline.

15. It assumes block comments do not nest

This is my favourite, because the tool was wrong about a language feature in order to be wrong about dead code. Three live modules in globset — ripgrep's glob matcher — came out as unreachable. The modules are declared at the top of lib.rs:

mod fnv;
mod glob;
mod pathutil;

Plainly alive. But above them sits a doc comment that documents glob syntax, and it contains this:

/*!
Match globs such as `src/**/*.rs` across platforms.
*/

Look at src/**/*.rs as bytes rather than as a glob. It contains /*, and then it contains */. Rust block comments nest, so the compiler counts one opened and one closed, and the comment continues to the real */. My scanner did not nest, ended the comment at the first */ inside the glob pattern, and treated the remaining prose as code — losing 354 lines of the file, including every mod declaration below it.

Go block comments, for the record, do not nest. So this is not one rule but two, and a shared scanner has to be told which language it is reading.

The same pass had to learn that '"' is a Rust character literal and not the start of a string — otherwise that quote opens a string that runs to the end of the file — while &'a str is a lifetime and not a character literal at all. The closing quote is what tells them apart.

What the list is worth

After all fourteen, pointed at three well-maintained repositories, the tool reports no missing production dependencies on any of them — because there are none. Pointed at a real in-house monorepo, it found 14 undeclared imports and 8 dead files that were all genuinely undeclared and genuinely dead.

That is the only benchmark that matters for this kind of tool: silence on healthy code. Anything that lists findings on requests and flask is telling you about itself, not about them.

See the reports

All five are here, unedited:

RepositoryReportWhat it found
requestsrequests.html95% of shipped modules test-reachable, no missing deps, 4 keys all in test fixtures
flaskflask.html96% reachable, 16 years of history, app.py at 139 commits is the hotspot
expressexpress.htmllib/response.js at 397 commits, 25 demo apps correctly kept out of the headline
cobra (Go)cobra.html100% test-reachable, command.go at 252 commits, go.mod read for dependencies
ripgrep (Rust)ripgrep.html63% reachable by import — most of its testing is integration tests that run the built binary, which no import graph can see

That last line is the kind of finding worth having. 63% is not a complaint about ripgrep's testing; it is a true statement about what imports reach, and the gap is exactly where a static reader has to admit what it cannot see.

The tool is Repo X-Ray. Python, JavaScript/TypeScript, Go and Rust get the full import graph; any other language is inventoried and explicitly not judged by a graph that never read it. It executes nothing, needs no network, has no dependencies, and writes one self-contained HTML page you can hand to a client.

Repo X-Ray — $39

More measured notes on coding agents: alexenabled.github.io