openrewrite / openrewrite/rewrite-static-analysis
EmptyBlock and RemoveMethodsOnlyCallSuper delete blocks and methods whose only content is a comment
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 62
- Forks
- 112
- Avg merge
- 1d 19h
- Merged PRs (30d)
- 40
Description
EmptyBlock and RemoveMethodsOnlyCallSuper both decide what to remove by looking at the statement list, without considering the comments attached to it. A block whose body is only a comment counts as empty, and an override whose body is a comment plus the super call counts as only calling super.
I would like to know how you see it before I suggest anything:
- Is this the intended behavior? There is a reasonable reading where a comment is not code, so a block containing only a comment really is empty.
- If it is intended, is it nonetheless a problem worth changing? The removal compiles cleanly, so nothing fails and the note is simply gone.
- If it should change, should the recipes always preserve a commented block or method, or should this be configurable?
It matters to me because the comments being deleted are TODOs recording work that still needs doing at exactly that spot. Several are reminders that a method needs a real implementation rather than the super call currently standing in for one.
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
Start by reading the EmptyBlock and RemoveMethodsOnlyCallSuper recipes and tracing how each inspects statement lists versus attached comments. The issue does not name tests or files beyond these recipes; done would require an agreed policy for comment-only bodies and corresponding behavior coverage.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100