palantir / palantir/palantir-java-format
Unlucky formatting for array literals at just above line length
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 907
- Forks
- 101
- Avg merge
- 1d 3h
- Merged PRs (30d)
- 19
Description
What happened?
The following formatting is produced by Palantir (we run it as a plugin to Spotless), version 2.28.0:
private static final int[] ACCESSORY_SLOTS = {RING_1_SLOT_NUM, RING_2_SLOT_NUM, BRACELET_SLOT_NUM, NECKLACE_SLOT_NUM
};
It does not look pretty. :-(
As soon as you add one additional character, it looks much better:
private static final int[] ACCESSORY_SLOTS = {
RING_1_SLOT_NUM, RING_2_SLOT_NUM, BRACELET_SLOT_NUM, NECKLACE_SLOT_NUM2
};
or if you remove two characters:
private static final int[] ACCESSORY_SLOTS = {RING_1_SLOT_NUM, RING_2_SLOT_NUM, BRACELET_SLOT_NUM, NECKLACE_SLOT_N};
(though I personally disagree with the lack of space surrounding the brace in this case)
What did you want to happen?
I would have expected it to look like in the one character longer example, since the closing brace did not fit on the same line as the opening brace:
private static final int[] ACCESSORY_SLOTS = {
RING_1_SLOT_NUM, RING_2_SLOT_NUM, BRACELET_SLOT_NUM, NECKLACE_SLOT_NUM
};
Contributor 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.
Research direction
Start with the array-literal examples and the line-length boundary described in the issue, then trace the formatter behavior for Java array literals around the closing brace. Done means the one-character-short case is formatted like the one-character-long example, with the opening and closing braces on separate lines.
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