openrewrite / openrewrite/rewrite-static-analysis

DefaultComesLast recipe creates duplicate case

Open
#289 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Java
Stars
62
Forks
112
Avg merge
1d 19h
Merged PRs (30d)
40

Description

If default comes before a case and simply continues into that case

      default:
      case DERIVATION_MODE:
        System.out.println("default");
        break;

refactoring with org.openrewrite.staticanalysis.DefaultComesLast from org.openrewrite.recipe:rewrite-static-analysis:1.6.0 results in a duplicate case and code duplication

      case DERIVATION_MODE:
        System.out.println("default");
        break;
      case DERIVATION_MODE:
      default:
        System.out.println("default");

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the Java switch example with org.openrewrite.staticanalysis.DefaultComesLast from rewrite-static-analysis:1.6.0, then inspect the recipe implementation and its existing tests. Done means the transformation no longer creates a duplicate case or duplicates the default branch, with a regression test covering this input.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.