Releases: OldJii/dead-code-pruner
Releases · OldJii/dead-code-pruner
v1.1.0 - Semantic dead-code pruning
Highlights
- Reworked the tool into a tree-sitter powered
prunerpackage withpython3 -m prunerandrun_pruner.pyentry points. - Added a 3-phase iterative pipeline: constant/control-flow simplification, constant-return method inlining, and conservative dead-method cleanup.
- Expanded language coverage for Java, Kotlin, Go, C, C++, JavaScript, TypeScript, Rust, Swift, and C#.
- Added project-level semantic analysis: method scanning, reference indexing, class hierarchy checks, and conservative method safety promotion.
- Improved semantic cascade cleanup so method inlining and dead-method replacement continue into
if true/falsebranch elimination. - Added dynamic-entry protection for Swift/iOS selectors and Storyboard/XIB references.
- Added multi-language and project-level regression suites, including full-pipeline Java/Swift/iOS semantic cases.
Usage
pip install -r requirements.txt
python3 -m pruner /path/to/project --dry-run
python3 -m pruner /path/to/projectNotes
This release is intentionally conservative: annotated/framework-managed methods, dynamic references, and potentially external entry points are preserved unless the tool can safely prove the cleanup path.
v1.0.0 - Initial Release
dead-code-pruner v1.0.0
A config-driven static analysis tool that eliminates dead code produced by constant folding in Java/Kotlin projects.
Features
- Config-driven: Define boolean expressions and their constant values in a YAML/JSON config
- 6-step pipeline: constant replacement → boolean simplification → compound boolean → if-block elimination → method inlining → dead method cleanup
- Iterative convergence: Each phase loops until no more changes are found
- Operator precedence aware: Correctly handles
true || A && B→true(notB) - Inheritance-aware: Builds class hierarchy to protect interface implementations, abstract methods, and
@Overridemethods - Comment/string safe: All replacements skip comments and string literals
- Zero dependencies: Pure Python 3.8+, no external packages required (PyYAML optional)
Quick Start
cp pruner.example.yaml pruner.yaml
# Edit pruner.yaml with your constants
python3 prune.py /path/to/your/project