unused_code_cleaner 1.1.0
unused_code_cleaner: ^1.1.0 copied to clipboard
A comprehensive Dart package to identify and remove unused assets, functions, packages, and files with detailed colored logging.
Changelog #
1.1.0 MAJOR BUG FIXES & SAFETY IMPROVEMENTS #
🚨 CRITICAL UPDATES - FIXES MAJOR DATA LOSS BUGS
Critical Bug Fixes: #
File Discovery Mismatch (CRITICAL)
- FIXED: Package was only scanning
lib/directory for references but checking ALL project files for being "used" - IMPACT: Files outside
lib/(test/, example/, etc.) were incorrectly marked as unused and deleted - SOLUTION: Now scans ALL Dart files in project from the beginning
Asset Analysis Scope Issue
- FIXED: Asset analyzer was only looking for references in limited file set
- IMPACT: Assets referenced from test files or other directories were marked as unused
- SOLUTION: Now scans all Dart files for asset references
Safety Validation Order
- FIXED: System directory validation was happening after pubspec.yaml check
- IMPACT: System directories failed with wrong error message
- SOLUTION: Moved system directory check to happen FIRST
Major Safety Improvements: #
Enhanced File Protection
- ADDED: Protection for Firebase files, generated files, example/, test/, integration_test/
- ADDED: Protection for platform-specific directories (android/, ios/, web/, windows/, macos/, linux/)
- ENHANCED: Exclusion patterns for .vscode/, .idea/, .gradle/ directories
Critical Safety Validation
- ADDED: Comprehensive safety validation that warns when >75% of assets or >30% of total items marked for deletion
- ADDED: Detailed analysis summary with recommendations
- ADDED: Extreme caution warnings for suspicious results
Asset Analysis Safety
- ADDED: Specific safety validation in asset analyzer
- ADDED: Warnings when unusual numbers of assets marked for deletion
- ADDED: Debugging information for analysis results
Pattern Matcher Improvements
- ENHANCED: Cross-platform path normalization
- ADDED: Better Windows path handling
- IMPROVED: System path detection and exclusion
Breaking Changes: #
- None - All changes are backwards compatible and improve safety
Migration Guide: #
- RECOMMENDED: Always use
--dry-runfirst to preview changes - REQUIRED: Update from any version before 1.1.0 immediately due to critical bugs
- SUGGESTED: Review exclude patterns if you have custom exclusions
Example Usage: #
# SAFE: Always preview first
unused_code_cleaner --dry-run --all --verbose
# SAFER: Target specific types with exclusions
unused_code_cleaner --assets --exclude "assets/icons/**" --dry-run
# PRODUCTION: Only after reviewing dry-run results
unused_code_cleaner --assets --interactive
1.0.1+hotfix.1 Documentation Safety Update #
Documentation Updates: #
- ADDED: Critical safety warnings in README.md
- ENHANCED: Installation instructions with version safety notes
- ADDED: Comprehensive safety features section
- UPDATED: Version constraints to ensure users get safe version
1.0.1+hotfix CRITICAL SAFETY UPDATE #
🚨 EMERGENCY HOTFIX - ALL USERS MUST UPDATE IMMEDIATELY
Critical Bug Fixes: #
- FIXED: Catastrophic file deletion bug in file analyzer that was removing ALL files instead of just unused ones
- FIXED: Overly broad
contains()matching in_isSpecialFile()method - ADDED: Self-analysis prevention - package cannot analyze itself
- ADDED: System directory protection - prevents analysis of C:, Windows, Program Files, etc.
- ADDED: Default exclusion patterns for generated files, build artifacts, git files
- ENHANCED: Multi-level confirmation dialogs with detailed file lists before deletion
- IMPROVED: Specific path pattern matching instead of dangerous substring matching
Safety Features Added: #
- Pattern normalization and cross-platform path handling
- Comprehensive system path validation
- Enhanced error messages and warnings
- Automatic exclusion of .git, .dart_tool, build/, *.g.dart, etc.
⚠️ Version 1.0.0 Advisory: #
DO NOT USE version 1.0.0 - contains critical bug that can delete entire projects. All users must upgrade to 1.0.1+hotfix immediately.
1.0.0 #
- Initial release
- Features:
- Detect and remove unused assets
- Detect and remove unused functions
- Detect and remove unused packages
- Detect and remove unused files
- Colored logging with detailed reports
- Interactive cleanup mode
- Support for exclude patterns and include paths