The AutoRefactor project delivers free software that automatically refactor code bases.
The aim is to fix language/API usage in order to deliver smaller, more maintainable and more expressive code bases.
The first software will be an Eclipse plugin to automatically refactor Java code bases. License will be dual licensed under EPLv1.0 and GPLv3+.
After years working in different large code bases, I (Jean-Noël Rouvignac) got tired of spending too much time applying the same code cleanups again and again.
In addition, tools like SonarQube™ (providing their own Java analyzer and also supporting the aggregation of FindBugs™, Checkstyle and PMD) are fantastic, but they do not not help fix the thousand warnings you can find in legacy code bases.
I decided I had spent too much time on manually doing these changes, so I tried using regular expressions. They work great for some code transforms, but can only do so much: they do not understand the language semantics, reapplying them again and again consumes time, they sometimes fail to execute due to too much complexity. I then sought for better and libre solutions, but found none. This is when I started AutoRefactor.
Software rots, particularly if the developers in charge do not care enough. Software has to be nurtured like a garden. Other causes for software rot are:
- developers lack of knowledge of the language in use and its features/idioms
- developers habits coming from other languages (Any C programmers around?)
- new language features get added, but the code base lags behind
- incomplete automatic changes are applied
- short deadlines, lack of investment in the software, lack of stakeholder support for reducing the technical debt
- Easier maintenance
- Modernized code base
- Leaner and more compact code base
- Performance improvements
Look at the samples showcasing each refactorings available in AutoRefactor.
The samples are extracted from the unit tests suite.
There are several ways to use AutoRefactor:
Alternatively, you can open a Java file, or select one or several files, packages or Java project, then right-click >
- Open a Java file, then type
Shift+Alt+Y to automatically refactor the code
- In the package explorer, you can also select one or several Java files, packages or Java projects and type
Shift+Alt+Y. The AutoRefactor plugin will apply the refactorings to all the selected Java files, or to the Java files located under the selected packages or under the Java projects.
You can see which changes have been applied in the "Git Perspective" (git) or the "Team Synchronizing" perspective (CVS, Subversion).
You can also see which changes have been applied by looking at individual files Local history, and comparing the last revision with the previous revision.
Automatic refactoring will automatically refactor the code
Choose refactorings... will allow to choose which refactorings to automatically apply
Developers are responsible for what they commit.
Since each commit should have a single purpose, it is recommended to separate code refactorings from features/bug fixes, and commit them separately from each other. See Martin Fowler's Preparatory refactoring from Workflows of Refactoring.
How to do mass refactorings?
The suggested approach is to run only one refactoring rule at a time to do single purpose commits. Once the refactoring rule has finished running, do a pre-commit code review to check all the changes are approved by the developer. Commit the change, then move on to run the next refactoring rule and start the same process until all rules have been applied and all the changes have been committed.
From now on, a developer can run the whole suite of refactorings without being overwhelmed by all the changes to review.
2015-03-23 - v1.0.0 is out!
Many refactoring rules based on pattern matching are part of the release. Give it a try!
From the Eclipse marketplace
Drag to your running Eclipse workspace to install AutoRefactor:
From AutoRefactor update site
- Go to
Install New Software...
- Click the
Add... button on the right
- Enter "AutoRefactor Releases" in the
- Enter "http://autorefactor.org/releases/" in the
Programming Languages >
- Click the
Next > button at the bottom
- Click the
Next > button at the bottom
- Accept the terms of the license agreement
- Click the
Finish button at the bottom.
nightly (maybe unstable)
For more adventurous users, nightlies (potentially unstable) are available at "http://autorefactor.org/nightly/".
How to Contribute
Please support this project if it was useful to you.
Consider the alternative: how much would it cost you to manually fix all the code?
- Donate the amount of technical debt you saved by using AutoRefactor,
- Donate 1$ per 10 lines of code removed,
Please contact me if you would like to sponsor a feature.
- Contribute refactoring ideas
- Test new refactorings on mature code bases
- Contribute new refactorings
- Eclipse Java development tools (JDT), the base for this plugin
- UCDetector: Unnecessary Code Detector, eclipse plugin that finds unnecessary (dead) public java code; suggests to the reduce visibility of methods, fields, classes; and make fields final. It offers to fix the reported issues in a batch mode.
- FindBugs™ and fb-contrib™, bytecode-based software flaw finder for Java programs
- Checkstyle, coding conventions checker for Java programs
- PMD, source-based software flaw finder for Java programs
- SonarQube™ provides its own Java static analyzer and also support the aggregation of the results of the precedent three software in a unified and coherent interface. It adds code coverage measurement and computes a lot of useful source code metrics. It is very useful for managing the health of source code and technical debt.
- walkmod, a tool for Java source code that share common goals with AutoRefactor
- Coccinelle, a fantastic source of inspiration for automated source-to-source transformations
- Pfff, a continuation of Coccinelle that can be used with several languages
Find here several books inspiring everyday how and why this plugin is written:
- The book Refactoring: Improving the Design of Existing Code by Martin Fowler, Kent Beck, John Brant, William Opdyke, Don Roberts and refactoring.com, its companion website
- The book Design Patterns: Elements of Reusable Object-Oriented Software by Erich Gamma, Richard Helm, Ralph Johnson, John Vlissides
- The quote
Programming is the art of telling another human being what one wants the computer to do. by Donald Knuth
Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.
This website is (C) 2013-2014 The AutoRefactor project and is licensed under the terms of the Creative Commons Attribution-ShareAlike 3.0