[2.10.0] Wrongly removes parentheses
Maintainers usually reply within 2 days
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 52/100
Research direction
Reproduce the issue with the Java snippets and --print-width 80, then trace the formatter logic responsible for removing parentheses. Done means the first expression retains parentheses so its meaning is unchanged, while the reported formatting behavior is covered by a regression check.
Written by the indexing model from the issue text.
Description
Prettier-Java 2.10.0
--print-width 80
Input:
return a != null && (b == c);
(minimumRelevanceScore * 2) - 1;
Output:
return a != null && b == c;
minimumRelevanceScore * 2 - 1;
Expected behavior:
Unchanged.
The second line is not technically incorrect but I personally don't like parentheses removed in such expressions. There is a long-standing issue in Prettier for JS for the same thing. The first one is wrong because it changes the meaning of the program.
P.S. I now see that Prettier for JS does the same thing. Horrible. And maybe it's because of the same issue. I would like Prettier for Java to be better than that! 😄
- Dominant language
- Java
- Stars
- 1.2k
- Forks
- 123
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 35
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing 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.
More from jhipster/prettier-java
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
jhipster/prettier-java#1113 ·
Maintainers usually reply within 2 days
-
Difficulty 3/5 1-2 days Newbie friendliness 56/100
jhipster/prettier-java#1114 ·
Maintainers usually reply within 2 days
-
Text block containing a comment-like line with " or \ fails with "Comment was not printed"Possibly taken @sean0407 claimed this 1 day ago. Open
Difficulty 3/5 1-2 days Newbie friendliness 66/100
jhipster/prettier-java#1112 ·
Maintainers usually reply within 2 days
-
Difficulty 4/5 3-5 days Newbie friendliness 48/100
jhipster/prettier-java#1031 ·
Maintainers usually reply within 2 days
-
Adds needlessly parenthesesPossibly taken @braxtonzhangio claimed this 74 days ago. Open
Difficulty 3/5 1-2 days Newbie friendliness 67/100
jhipster/prettier-java#1001 ·
Maintainers usually reply within 2 days
All issues in jhipster/prettier-java
Similar issues
-
bug/错误
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
FCL-Team/FoldCraftLauncher#1951 ·
Maintainers usually reply within 4 days
-
Difficulty 1/5 Under an hour Newbie friendliness 68/100
quarkusio/quarkus-agent-mcp#296 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
commons-app/apps-android-commons#7072 ·
Maintainers usually reply within 1 day
-
enhancement web-ui
Difficulty 2/5 1-3 hours Newbie friendliness 67/100
jenkinsci/jenkins#27583 · 2 comments ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100