← All recipes
Moderne licensed

Merge collapsible if statements

Recipe IDorg.openrewrite.golang.codequality.MergeCollapsibleIfArtifactgithub.com/moderneinc/recipes-go

Merge nested if statements into a single if with && when neither has an else clause and the outer body contains only the inner if.

Single recipeProprietary

Usage

This recipe has no required configuration options. You’ll need the Moderne CLI configured before running the command below.

mod run . --recipe org.openrewrite.golang.codequality.MergeCollapsibleIf

If the recipe isn’t available locally, install it with:

mod config recipes go install github.com/moderneinc/recipes-go