Stellarion identifies several categories of unused code:
Functions that are defined but never called anywhere in the codebase:
Declared values that are never read:
Import statements that bring in unused symbols:
Exports that no other module imports:
Code paths that can never execute:
return, throw, or breakStellarion reports unused code in lines:
| Unused Lines | Severity | Impact |
|---|---|---|
| 0-100 | Low | Minimal cleanup needed |
| 100-300 | Moderate | Schedule cleanup |
| 300-500 | High | Prioritize removal |
| >500 | Critical | Significant maintenance burden |
The metric accounts for:
Unused code ships to users, increasing:
Modern bundlers can tree-shake some unused code, but not all patterns are shakeable.
Dead code creates ongoing costs:
Unused code can harbor:
Every line of code is a line developers must process:
Features get removed but their implementation remains:
// Feature flag removed, code stayed
export function legacyCheckout() { ... } // Never called
Code that was replaced but not deleted:
// Old implementation kept "just in case"
function processDataV1() { ... } // Superseded by processDataV2
Copied code brought along unnecessary pieces:
// Copied from another module, helper never used here
function unusedHelper() { ... }
Code written for requirements that never materialized:
// "We might need this someday"
export function futureFeature() { ... } // YAGNI violation
Edge cases that can't actually occur:
if (typeof window === 'undefined' && typeof global === 'undefined') {
// This can never execute in any JS environment
}
Run Stellarion's unused code detection to identify candidates:
# Generate report of unused code
stellarion analyze --focus unused
Before removing, verify the code isn't:
eval() or dynamic import()Check for string-based usage:
# Search for function name as string
grep -r "functionName" --include="*.ts" --include="*.json"
Remove or update tests for deleted code:
no-unused-vars, no-unreachablenoUnusedLocals, noUnusedParametersFor the complete metrics reference, see Stellarion Quality Metrics.