Note
An IntelliJ IDEA plugin for automatically detecting and removing deprecated controller methods and cleaning up unused code.
Version: 0.0.3
Deprecated Controller Remover is an IntelliJ plugin that intelligently analyzes your Java/Spring codebase to identify and safely remove deprecated controller methods and unused code elements.
This plugin helps maintain clean, efficient codebases by:
- Detecting deprecated controller methods that are no longer in use
- Removing any unused fields (not just final private) to reduce memory footprint
- Cleaning up unused imports to improve code readability
- Removing empty classes to streamline code structure
- Providing detailed analysis reports of all cleanup operations
- Ensuring safe removal with comprehensive usage analysis
- Identifies deprecated methods in Spring controllers with
@Controllerand@RestControllerannotations - Analyzes usage patterns across the entire project using PSI tree traversal
- Safely removes unused deprecated methods from controllers
- Provides detailed reporting of what was removed
- Tool Window: Dedicated console interface for monitoring deprecated controller removal operations
- Unused Field Removal: Automatically removes any unused fields (not just final private)
- Import Optimization: Cleans up unused import statements
- Class Removal: Removes classes with no methods (more aggressive approach)
- Smart Analysis: Uses PSI tree traversal for accurate usage detection
- Safe Operations: Comprehensive validation before any code removal
- File Marking: Works with files marked with
//Controller Cleanercomment - Tool Window: Dedicated console interface for monitoring code cleanup operations
- Deprecated Controller Remover Tool Window: Black console-style interface for controller-specific operations
- Code Cleanup Tool Window: Black console-style interface for general code cleanup operations
- Real-time Progress: Live updates during cleanup operations
- Detailed Logging: Comprehensive logging of all operations and results
- Side-by-side Operation: Both tool windows can be used simultaneously
- Comprehensive usage analysis before removal
- Respects framework annotations and dependencies
- Preserves code that might be used by reflection or external tools
- Validates method usage across the entire project
- Multiple cleanup passes to catch newly unused elements
- User confirmation dialogs for all operations
- Clone the repository:
git clone https://github.com/WeyeTech/DeprecatedControllerRemover.git - Build the plugin:
./gradlew buildPlugin - Install the generated
.jarfile frombuild/distributions/in IntelliJ IDEA - Restart your IDE
- Open IntelliJ IDEA
- Go to Settings/Preferences > Plugins
- Search for "Deprecated Controller Remover"
- Click Install and restart your IDE
Note
Version 0.0.3 is currently available for development builds. Marketplace release coming soon.
- Open your Java/Spring project in IntelliJ IDEA
- Go to Tools > Deprecated Controller Remover
- The Deprecated Controller Remover tool window will appear at the bottom with a black console interface
- Review the analysis results in the dialog and console output
- Confirm the cleanup operation
- Mark files for cleanup by adding
//Controller Cleanercomment at the top of Java files - Go to Tools > Clean Marked Files
- The Code Cleanup tool window will appear at the bottom with a black console interface
- Review the analysis results showing unused imports, fields, and classes with no methods
- Confirm the cleanup operation
- Both tool windows appear as buttons in the bottom tool window area
- Click on either button to open the respective console interface
- Both windows provide real-time logging and progress updates
- Operations can be run independently or simultaneously
The plugin works out-of-the-box with sensible defaults:
- File Marking: Add
//Controller Cleanerto Java files you want to clean up - Analysis Scope: Automatically analyzes the entire project
- Safety Checks: Comprehensive validation before removal
- Multiple Passes: Up to 3 cleanup passes to catch newly unused elements
- Progress Reporting: Detailed progress indicators and logging
- Java: Full support for Java projects with comprehensive PSI analysis
- Spring Framework: Specialized analysis for Spring controllers and annotations
- Maven/Gradle: Works with both build systems
- Kotlin: Basic support (coming in future versions)
This plugin is built using the IntelliJ Platform SDK and follows best practices for plugin development.
- IntelliJ IDEA 2023.1 or later
- Java 17 or later
- Gradle 8.0 or later
# Clone the repository
git clone https://github.com/WeyeTech/DeprecatedControllerRemover.git
# Navigate to the project directory
cd DeprecatedControllerRemover
# Build the plugin
./gradlew buildPlugin
# Run the plugin in a sandbox IDE
./gradlew runIde
# Run tests
./gradlew testsrc/main/kotlin/
βββ com/wheelseye/
βββ codecleanup/
β βββ action/
β β βββ CodeCleanupAction.kt # Code cleanup UI actions
β βββ service/
β β βββ CodeCleanupService.kt # Code cleanup logic (imports, fields, empty classes)
β βββ toolWindow/
β βββ CodeCleanupToolWindowFactory.kt # Code cleanup tool window factory
β βββ CodeCleanupToolWindowPanel.kt # Code cleanup tool window UI
β βββ CodeCleanupToolWindowService.kt # Code cleanup tool window service
βββ deprecatedcontrollerremover/
βββ action/
β βββ DeprecatedControllerRemoverAction.kt # Deprecated controller remover UI actions
βββ service/
β βββ DeprecatedControllerRemoverService.kt # Deprecated controller remover logic (deprecated methods)
βββ toolWindow/
βββ DeprecatedControllerRemoverToolWindowFactory.kt # Deprecated controller remover tool window factory
βββ DeprecatedControllerRemoverToolWindowPanel.kt # Deprecated controller remover tool window UI
βββ DeprecatedControllerRemoverToolWindowService.kt # Deprecated controller remover tool window service
The deprecated controller remover uses IntelliJ's PSI (Program Structure Interface) to analyze Spring controllers:
- Controller Detection: Identifies classes with
@Controlleror@RestControllerannotations - Deprecated Method Analysis: Finds methods marked with
@Deprecatedannotation - Usage Analysis: Traverses the PSI tree to find references using ReferencesSearch
- Safety Validation: Ensures deprecated methods aren't used by active code
- Safe Removal: Deletes unused deprecated methods with user confirmation
The code cleanup analyzes files marked with //Controller Cleaner:
- File Discovery: Scans for Java files with the cleanup marker
- Import Analysis: Identifies unused import statements (excluding java.lang.*)
- Field Analysis: Finds any unused fields (excluding public, static, and annotated fields)
- Class Analysis: Identifies classes with no methods (more aggressive approach)
- Multi-pass Cleanup: Runs up to 3 passes to catch newly unused elements
- Safe Removal: Deletes unused elements with comprehensive error handling
Both tool windows provide:
- Console Interface: Black background with white text for clear visibility
- Real-time Logging: Live updates during operations
- Progress Tracking: Detailed progress indicators
- Error Reporting: Comprehensive error messages and handling
We welcome contributions! Please see our Contributing Guidelines for details.
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature - Make your changes and add tests
- Run the test suite:
./gradlew test - Commit your changes:
git commit -m 'Add amazing feature' - Push to the branch:
git push origin feature/amazing-feature - Open a Pull Request
The plugin includes comprehensive tests:
# Run all tests
./gradlew test
# Run specific test categories
./gradlew test --tests "*DeprecatedControllerRemover*"
./gradlew test --tests "*CodeCleanup*"
# Run with coverage
./gradlew test jacocoTestReportPlugin not detecting files
- Ensure your project is properly indexed
- Check that files are within the project scope
- Verify Java SDK is correctly configured
- Make sure the Java plugin is enabled
Code cleanup not working
- Ensure files are marked with
//Controller Cleanercomment - Check that the comment is at the top of the Java file
- Verify the file extension is
.java
False positives
- Review the safety settings
- Check for framework annotations
- Verify reflection usage patterns
- Ensure all dependencies are properly resolved
Tool windows not appearing
- Check that the plugin is properly installed
- Restart the IDE after installation
- Verify the tool window buttons are visible in the bottom area
If you encounter issues:
- Check the GitHub Issues for known problems
- Review the Wiki for detailed guides
- Join the Discussions for community support
This project is licensed under the MIT License - see the LICENSE file for details.
- Issues: Report bugs and request features on GitHub Issues
- Discussions: Join the conversation on GitHub Discussions
- Documentation: Check our Wiki for detailed guides
- Enhanced Spring controller detection with more annotation types
- Kotlin language support
- Custom cleanup rules configuration
- Integration with CI/CD pipelines
- Performance optimization for large codebases
- IDE theme integration
- Batch processing improvements
- More detailed reporting and analytics
- Custom file marking patterns
- Export cleanup reports
- Built with the IntelliJ Platform Plugin Template
- Inspired by the need for automated code cleanup in large Java/Spring projects
- Community feedback and contributions
- JetBrains for the excellent IntelliJ Platform SDK
See CHANGELOG.md for a complete list of changes and version history.
- Dual Tool Window System: Separate tool windows for controller removal and code cleanup
- Enhanced Code Analysis: Multi-pass cleanup with comprehensive PSI-based analysis
- Improved User Experience: Real-time progress tracking and detailed logging
- Safety Features: Comprehensive validation and user confirmation dialogs
- Spring Framework Integration: Specialized analysis for Spring controllers