Published Jul 16, 2024

SE Radio 625: Jonathan Schneider on Automated Refactoring with OpenRewrite

Jonathan Schneider, cofounder of Moderne, delves into the transformative capabilities of OpenRewrite, a tool that automates software maintenance with AI-powered refactoring, recipe collaboration, and multi-language support, ultimately enabling developers to modernize code and address security vulnerabilities efficiently across repositories.
Episode Highlights
Software Engineering Radio - the podcast for professional software developers logo

Popular Clips

Episode Highlights

  • Purpose

    Jonathan Schneider, cofounder of Moderne and creator of OpenRewrite, discusses the tool's core purpose and benefits. OpenRewrite is designed for automated refactoring, which involves writing software that rewrites other software to modernize it, fix security vulnerabilities, and ensure code consistency 1. Schneider explains that OpenRewrite combines a rich set of data about a codebase with programs called recipes to make changes 1. He notes, "Automated refactoring is writing software that rewrites other software, and its main benefits are to achieve some modernization in that software to fix security vulnerabilities and to ensure a consistent style or fix these inconsistencies in codebases" 1.

       

    Correctness

    Ensuring correctness in refactoring is crucial, and OpenRewrite achieves this through syntax trees and type attribution. Jonathan Schneider highlights that type attribution is essential for ensuring that changes are correct and stylistically consistent with the existing codebase 2. He explains that parsers convert code into a lossless semantic tree, which retains necessary information for refactoring without losing original code details 3. Schneider states, "Type attribution is one of the essential elements of correctness in a recipe" 2.

       

    Scenarios

    OpenRewrite is versatile, allowing developers to use it on local machines or within CI/CD pipelines. Schneider explains that it can be used for various tasks, from linting in CI to patching security vulnerabilities on developer workstations 4. He provides examples like updating dependencies across multiple repositories or migrating APIs, showcasing its utility in handling complex code changes 5. Schneider notes, "Whenever gradle releases a new version, we will do a mass commit to all of our 100 repositories to update that to our gradle builds to the latest" 4.

Related Episodes