Skip to content

if statements with literal conditions and jumps in their branches aren't simplified #192

@tkindy

Description

@tkindy

What version of OpenRewrite are you using?

I am using

  • OpenRewrite v8.7.2
  • Maven plugin v5.8.1
  • rewrite-static-analysis v1.0.8

How are you running OpenRewrite?

I am using the Maven plugin, and my project is a single module project.

<plugin>
  <groupId>org.openrewrite.maven</groupId>
  <artifactId>rewrite-maven-plugin</artifactId>
  <version>5.8.1</version>
  <configuration>
    <activeRecipes>
      <recipe>org.openrewrite.staticanalysis.SimplifyConstantIfBranchExecution</recipe>
    </activeRecipes>
  </configuration>
  <dependencies>
    <dependency>
      <groupId>org.openrewrite.recipe</groupId>
      <artifactId>rewrite-static-analysis</artifactId>
      <version>1.0.8</version>
    </dependency>
  </dependencies>
</plugin>

What is the smallest, simplest way to reproduce the problem?

class A {
  public int foo() {
    if (true) {
      return 5;
    }
    return 6;
  }
}

What did you expect to see?

class A {
  public int foo() {
    return 5;
  }
}

What did you see instead?

class A {
  public int foo() {
    if (true) {
      return 5;
    }
    return 6;
  }
}

What is the full stack trace of any errors you encountered?

No errors.

Are you interested in contributing a fix to OpenRewrite?

Yes, I'm interested in contributing a fix.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions