Auto-Refactor Code

CodeScene has always been great at identifying code smells and prioritizing them. With our AI-based Auto-Refactor capability we make those insights actionable, too. Better: we also fact-check the AI code to ensure it makes the right thing, saving you a lot of time and guaranteeing that your refactorings are both correct and impactful.

Automated refactorings are available in CodeScene's VS Code extension.

Fig. 20 Get fact-checked automated refactorings directly in the IDE.

How is CodeScene Auto-Refactor different from other AI-assistants?

As pointed out the in Forbes article on the Promises and Risks of AI, AI-assisted coding is still in its infancy. Our own benchmarking study, Refactoring vs Refuctoring, shows that existing AI solutions only deliver functionally correct refactorings in 37% of the cases.

This implies that we have to adopt Generative AI with caution and guardrails, otherwise the AI will break our code and introduce more problems than it solves. Enter CodeScene’s Auto-Refactor: our main innovation is that we fact-check the responses from the AI to ensure the refactoring preserves the semantic behavior of the code, as well as guaranteeing that the refactoring actually improves the Code Health.

Integrate Auto-Refactor in your development flow

  1. Make sure you have installed the local code review tool, CodeScene CLI tool. When making a commit, CodeScene CLI checks for any new Code Health issues, and offers to Auto-Refactor when applicable/doable.

  2. Enable Auto-Refactor in CodeScene’s VS Code extension. The VS Code extension will identify the code smells that can be automatically refactored, and indicate them in the IDE. Click on the Auto-Refactor action to inspect and apply a refactoring.

Please note that we have additional IDEs like IntelliJ and Visual Studio on our roadmap, and Auto-Refactor will come to those IDEs too.

NOTE: The Auto-Refactor is available as a preview release by invitation for all paid CodeScene subscriptions. Sign-up here to enable Auto-Refactor for your code.

Supported Programming languages

CodeScene’s Auto-Refactor capability is available for the following programming languages:

  • JavaScript

  • TypeScript

We’ll continue to expand the Auto-Refactor capabilities to languages such as Java, C#, Golang, etc. Missing your favorite language? Feel free to Contact us with a feature request.

Refactoring Scope

Currently, we support Auto-Refactor of the following code smells: Deep Nested Logic, Bumpy Road, Complex Conditional, and Complex Method. Support for auto-refactoring more code smells will come in subsequent releases. The vision is to support automated fixes of all Code Health issues, so that you can – safely – clean-up any code.