Mountainous-Scale Automated Source Code Refactoring with OpenRewrite

by

OpenRewrite enables big-scale distributed offer code refactoring for framework migrations, vulnerability patches, and API migrations with an early focal point on the Java language.

The OpenRewrite mission is a semantic code search and transformation ecosystem for Java and utterly different offer code. It features a platform of prepackaged refactoring recipes for overall framework migration and stylistic consistency initiatives. It furthermore skill that you just can justify customized recipes to invent a big quantity of offer code transformations.

OpenRewrite works by making adjustments to Abstract Syntax Timber (AST) representing your offer code and printing the modified bushes serve into offer code. You’re going to then overview the adjustments to your code and commit. Adjustments to the AST are performed in Company and placement visitors are aggregated into Recipes. OpenRewrite recipes invent minimally invasive adjustments to your offer code that honor the authentic formatting.

As an instance, if you will must constantly consume static imports across your total test files, in role of doing this manually, you would consume the UseStaticImport visitor supplied by OpenRewrite. Applied to the file below, you would behold the adjustments this generates.

import org.junit.Inform;

...

Inform.assertTrue(situation);

import static org.junit.Inform.assertTrue;

...

assertTrue(situation);

In Getting Started, we will learn configure Maven/Gradle so that you just would possibly want to add OpenRewrite as a dangle step after which consume the instruments to originate from transformations.