showcase Dead code detection for 19 languages with one table and no call graph
I wanted dead-code removal that works the same in Python, Go, TypeScript, Rust, Lua and the rest, without a parser per language.
The rule is a count: a name is dead when every mention of it is inside its own definition. Any other mention anywhere (another file, a string, a template, a YAML file) keeps it alive.
- One scanner blanks comments and strings for every language, from a table entry.
- A definition is a regex plus how its block ends: braces, indentation or an end keyword.
- A count can miss dead code. It can't invent it.
- Then the project's own tests run after every deletion, and whatever breaks them is put back.
What a count can't see (a public method called through an interface, a subclass a framework registers) is marked risky and left for a reviewer.
A language is about twenty lines in src/lang.rs.
1
Upvotes

