This is an experiment at writing a plugin for checkstyle
This plugin should search legacy code for coding patterns that can be expressed in a more idiomatic way in modern Java.
For example, since Java 7 it's better to use try-with-resources instead of closing resources in a finally block.
Most loop based code can be written more declaratively using filters and maps.
If not, for each
can be used instead of indexed for loops or iterators.
Since Java 9, there are many one liners for things that used to require verbose blocks of code.
java -classpath ./build/libs/checkIdioms-1.0-SNAPSHOT.jar:checkstyle-${projectVersion}-all.jar \
com.puppycrawl.tools.checkstyle.Main -c example-config.xml myproject
See https://checkstyle.sourceforge.io/writingchecks.html#Integrate_your_Check for more details.
This is still a work in progress. Don't rely on it working.
This project was inspired by Source Code Rejuvenation is not Refactoring.
All code is free to use under the MIT license.