openrewrite / openrewrite/rewrite-static-analysis

UnnecessaryParentheses should keep line breaks

Open
#219 0 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

This is more a discussion.

I am applying prettier-java to my project (https://github.com/JabRef/jabref/pull/10646). It turned out best (in comparison to GJF, palantir-java, spring-java-style). It has very good review-friendly line wrapping.

UnnecessaryParentheses undoes newlines in some cases

-        sb.append(
-            StringUtil.quote(
+        sb.append(StringUtil.quote(
...
            stringBuilder.append(
-                style.getNumCitationMarkerForBibliography(citedKey).toString()
+            stringBuilder.append(style.getNumCitationMarkerForBibliography(citedKey).toString()

Is it possible to turn-off this behavior - or move that behavior to another rule (maybe "ObsoleteNewLines", "CompressCode", ...)?


Link to failing test: https://github.com/JabRef/jabref/actions/runs/6905905922/job/18789707499?pr=10646

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 with the UnnecessaryParentheses rule and the failing test linked in the issue. Compare the shown before-and-after formatting to determine where line breaks are removed. Done means the rule preserves those breaks or its behavior can be disabled or separated as agreed.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.