openrewrite / openrewrite/rewrite-static-analysis
`FallThrough` should not add break when `switch` is last statement in a method requiring a `return`
Open
Nobody has claimed this yet.
bug
- Dominant language
- Java
- Stars
- 62
- Forks
- 112
- Avg merge
- 1d 19h
- Merged PRs (30d)
- 40
Description
In the following case
public class A {
public int m(int i) {
switch (i) {
case 0:
if (true) return i;
default:
throw new IllegalStateException();
}
}
}
the FallThrough recipe should not add a break statement after the if. The resulting code doesn't compile. Instead it would be better to add a // fall through comment here.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Locate the FallThrough recipe and its related tests in the repository, then reproduce the Java example from the issue. Verify the transformation no longer inserts a break after the conditional return when the switch is the final statement of a method requiring a return; done means the result compiles and uses a fall-through comment instead.
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
- 42/100