openrewrite / openrewrite/rewrite

Make AutoFormat ignore certain blocks

Open
#3,526 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Java
Stars
3.7k
Forks
570
Avg merge
13h 12m
Merged PRs (30d)
261

Description

In our projects we sometimes use a special comment to prevent our IDEs from formatting certain blocks:

 //@formatter:off
        Pageable pageable = this.privilegeSortMapping
                .chunkToPageable(new Chunk(0, Integer.MAX_VALUE,
                                List.of(new Chunk.Order("entity", Sort.Direction.ASC),
                                        new Chunk.Order("name", Sort.Direction.ASC))),
                        language);
        //@formatter:on

Sometimes the manuall formatting is prettier/more readable than the automatically formatted code. I think it would be cool if the AutoFormat-Recipe could be configured to turn formatting off in some cases.

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 locating the AutoFormat-Recipe entry point and its existing configuration and tests; the issue does not name specific files. Trace how formatting is applied around comments, then define completion as a configurable way for formatter-off and formatter-on blocks to remain unchanged and covered by tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.