Repository navigation
v0.19.0 - Dead-code detection across ten languages and across language boundaries
Until now scantool's dead-code detection opted in for three languages and only ever looked within one language at a time. Most languages produced nothing, and a handler reached from another language — a frontend calling a backend route — looked dead. This release extends it to ten languages and across language boundaries, while keeping the one rule that makes a "this is dead" claim worth trusting: it is never made on faith.
Dead code in ten languages, each on its own terms
A private function that nothing calls is a candidate everywhere. But "reachable" means something different in each language, and a signal that ignores that flags real API as dead. So each language was opted in only after measuring that its public surface is never touched — the same verify-before-opt-in rule that earlier caught Go, Rust and C# flagging their own exports.
- A Rust
pubfunction is API, and apub trait's default method is reached through the trait even though it carries nopubof its own — both are left alone; only a genuinely private, uncalled function is flagged. A naive first cut flagged the trait methods, and the fixture that asserts exports are never dead caught it before it shipped. - A React component used only as
<Card/>is no longer dead: JSX usage is now an edge in the call graph, which also means hot-function and centrality ranking finally see which components a UI leans on. - A C++
staticfunction unused in its file is flagged; a non-static one is left alone, because it may be called from a translation unit scantool never parses. Class members are judged by their access label, now also shown in the skeleton. - A Swift method that satisfies a protocol requirement stays reachable even when nothing in the codebase calls it, because a framework like
Codableor a UIKit delegate might. Where a type conforms to a protocol scantool cannot account for, the whole type is left alone rather than guessed at. - C#, Zig and PHP each got the verdict their visibility rules imply — implicitly-private C# members, non-
pubZig declarations, andprivatePHP methods are candidates; public, exported and magic members are not.
Ruby is the one language left silent, on purpose and after measuring rather than assuming. It has no module privacy, and send, method_missing and define_method dispatch leave no static declaration to resolve against, so any rule precise enough to be safe would stay silent in practice anyway. Its call graph was still repaired (below), so the rest of scantool works on it.
Across language boundaries
The call graph is per-language and cannot connect a route defined in one language to a URL that calls it in another. A directed reference map now resolves that link: it matches route handlers against the URL references that reach them, across FastAPI, Flask, NestJS and Spring as well as the imperative router.get('/path', …) style that Express, Hono and Fastify use, with consumers in any source or markup — a Swift app, a Kotlin app, another backend, a template.
It was validated against a real Zig-backend, TypeScript-backend, Swift-iOS wallet repository, which immediately surfaced two things synthetic tests had hidden: the backend registers routes imperatively rather than with decorators, and the iOS app's URL references were invisible until Swift was scanned as a consumer. With both fixed it resolved 57 routes across the language boundary with no false orphans.
What it deliberately does not do is guess past the edge of source. A route bound to a URL with no static link, a call into a compiled library, a remote service, a method named by string interpolation — these are reported as unresolvable rather than flagged. Resolving string-keyed dispatch where both ends are source is in scope; reading binaries or predicting runtime is not.
Why it stays quiet on healthy code
The dead-code signal points; it does not convict. Public and exported API is never flagged, decorated and framework-registered handlers are subtracted, and a name referenced anywhere — including in config, build scripts or another language — is treated as reachable. The orphan side of the reference map is precision-first the same way: a route with no distinctive path token is unresolvable rather than orphan, and endpoints consumed by contract from outside the repository — /.well-known/*, JWKS, robots.txt, static assets — are never called dead. On the test repository it produced no false orphans across all 57 routes.
Also
- The caller-resolution contract is now clean for every code language. Calls made inside closures, initializers, computed properties and dynamically-defined methods used to attribute to a name that resolved to nothing and silently vanish from the graph; they now attribute to the nearest real definition. For Swift this closed a 28% edge-loss, and it sharpens hot functions, centrality and divergence everywhere.
- The reachability rules, the predictions written before building them, and the measurements that confirmed or refuted them are kept in
experiments/.