OpenRewrite permits gigantic-scale disbursed source code refactoring for framework migrations, vulnerability patches, and API migrations with an early focal point on the Java language.
The OpenRewrite venture is a semantic code search and transformation ecosystem for Java and varied source code. It consists of a platform of prepackaged refactoring recipes for traditional framework migration and stylistic consistency projects. It also lets you give an explanation for custom recipes to create a profusion of source code transformations.
OpenRewrite works by making modifications to Abstract Syntax Trees (AST) representing your source code and printing the modified timber support into source code. You would possibly perchance then evaluate the modifications on your code and commit. Changes to the AST are performed in Visitors and company are aggregated into Recipes. OpenRewrite recipes originate minimally invasive modifications to your source code that honor the original formatting.
For example, when you happen to would maybe perchance smartly be attempting to want to consistently employ static imports across all of your check files, moderately than doing this manually, you presumably can employ the UseStaticImport visitor offered by OpenRewrite. Applied to the file below, you would maybe perchance presumably also explore the modifications this generates.
import org.junit.Assert;
...
?
Assert.assertTrue(situation);
import static org.junit.Assert.assertTrue;
...
?
assertTrue(situation);
In Getting Began, we’ll look for ways to configure Maven/Gradle to add OpenRewrite as a build step after which employ the instruments to build up from transformations.