Dead Code Certifier
Detect and certify dead code in TypeScript/JavaScript projects with confidence scoring. Unlike simple lint rules, Dead Code Certifier uses control-flow analysis and cross-file reference analysis via the TypeScript Compiler API to prove code is unreachable — and explicitly flags potential false positives so you can trust the results.
Features
Control-Flow Analysis
- Unreachable code after
return, throw, break, continue
- Dead branches in
if/switch with constant conditions (if (false), duplicate cases)
- Handles compound terminators (if/else where both branches return)
Reference Analysis
- Unused exports with no imports anywhere in the workspace
- Unused functions, variables, classes, interfaces, and type aliases
- Works across files using
ts.LanguageService.findReferences()
Dead Import Detection
- Default, named, namespace, and type-only imports
- Side-effect imports (
import './polyfill') are never flagged
Confidence Scoring (0–100)
Every finding gets a confidence score with a human-readable explanation:
| Tier |
Score |
Meaning |
| Definite |
95–100 |
Near-certain dead code. Safe to remove. |
| Very Likely |
70–94 |
Strong evidence. Manual review recommended. |
| Possible |
50–69 |
Moderate evidence. Needs investigation. |
| Uncertain |
0–49 |
Flagged as potential false positive. |
Score is adjusted based on context: decorators (-15), dynamic access (-20), entry point files (-25), underscore prefix (-30), multi-root workspace (-10).
False Positive Flagging
Findings that might be incorrect are explicitly marked with reasons:
- Entry point files (exports consumed externally)
- Decorator usage (Angular, NestJS, TypeORM)
- Dynamic property access (
obj[key], eval)
- JSX components (may be lazy-loaded)
- Magic/lifecycle methods (
toString, ngOnInit, render)
- Declaration merging (interfaces)
- Barrel files (re-exports)
@public/@api JSDoc tags
Display
- Inline diagnostics: Squiggly underlines with faded/dimmed styling and hover details showing confidence + reasoning
- Sidebar panel: Tree view grouped by file with confidence badges, sortable by file or confidence
Commands
| Command |
Description |
Dead Code Certifier: Analyze Workspace |
Scan all files in workspace |
Dead Code Certifier: Analyze Current File |
Scan the active editor |
Dead Code Certifier: Clear All Diagnostics |
Remove all findings |
Dead Code Certifier: Sort by Confidence |
Sort sidebar by confidence score |
Dead Code Certifier: Sort by File |
Sort sidebar by file path |
Configuration
| Setting |
Default |
Description |
deadCodeCertifier.enable |
true |
Enable/disable the extension |
deadCodeCertifier.analyzeOnSave |
true |
Auto-analyze on file save |
deadCodeCertifier.debounceMs |
500 |
Debounce delay for on-save analysis |
deadCodeCertifier.confidenceThreshold |
50 |
Minimum confidence to show (0–100) |
deadCodeCertifier.excludePatterns |
["**/node_modules/**", ...] |
Glob patterns to exclude |
deadCodeCertifier.entryPointPatterns |
["**/index.ts", ...] |
Entry point file patterns |
deadCodeCertifier.diagnosticSeverity |
"hint" |
Severity level: hint, information, warning, error |
deadCodeCertifier.rules.* |
true |
Toggle individual rules |
Rules
rules.unreachableCode — Unreachable code after terminators
rules.deadBranches — Dead branches with constant conditions
rules.unusedExports — Exports with no workspace references
rules.unusedFunctions — Unused function declarations
rules.unusedVariables — Unused variable declarations
rules.unusedClasses — Unused class declarations
rules.unusedTypes — Unused interfaces and type aliases
rules.deadImports — Unused import bindings
Supported Languages
- TypeScript (
.ts, .tsx)
- JavaScript (
.js, .jsx)
How It Works
- Reads your project's
tsconfig.json (falls back to sensible defaults)
- Creates a
ts.LanguageService for incremental, cross-file analysis
- Runs three analysis passes: control flow, references, imports
- Scores each finding and checks for false positive heuristics
- Displays results inline and in the sidebar panel
Known Limitations
- Dynamic imports (
import()) and require() calls are not fully traced
- Symbols accessed via
module.exports or CommonJS patterns may be missed
- Multi-root workspaces analyze each root independently (no cross-root references)
- Very large projects (10k+ files) may experience slower full workspace scans
License
MIT
| |