Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

[2.10.0] Wrongly removes parentheses

Open
#948 4 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 2 days

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
52/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Quiet
Tech stack
java
Domain
tooling

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

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 jhipster/prettier-java

All issues in jhipster/prettier-java

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.