EmptyBlock and RemoveMethodsOnlyCallSuper delete blocks and methods whose only content is a comment

Open
#1,050 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Needs clarification
Activity status
Active
Tech stack
java
Domain
devtools

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.

Description

bug

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.

Dominant language
Java
Stars
64
Forks
116
Avg merge
6h 52m
Merged PRs (30d)
144

Getting set up

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.

More from openrewrite/rewrite-static-analysis

All issues in openrewrite/rewrite-static-analysis

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.