palantir / palantir/palantir-java-format
Non-deterministic indentation when 2nd, 4th, etc arguments of methods are long
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 907
- Forks
- 101
- Avg merge
- 1d 3h
- Merged PRs (30d)
- 19
Description
What happened?
Both of the following indentation levels are allowed, and depending on what the state of the code was before running the formatter, it is non-deterministic which one is output.
Object object = foo(
foo,
veryVeryVerVeryVerVeryVerVeryVerVeryVerVeryVerVeryVerVeryVerVeryVerVeryVerVeryVerVeryVerVeryVeryyyyyyyyyyyyyVeryVeryLongVariableName,
foo,
veryVeryVerVeryVerVeryVerVeryVerVeryVerVeryVerVeryVerVeryVerVeryVerVeryVerVeryVerVeryVerVeryVeryyyyyyyyyyyyyVeryVeryLongVariableName);
Object object = foo(
foo,
veryVeryVerVeryVerVeryVerVeryVerVeryVerVeryVerVeryVerVeryVerVeryVerVeryVerVeryVerVeryVerVeryVeryyyyyyyyyyyyyVeryVeryLongVariableName,
foo,
veryVeryVerVeryVerVeryVerVeryVerVeryVerVeryVerVeryVerVeryVerVeryVerVeryVerVeryVerVeryVerVeryVeryyyyyyyyyyyyyVeryVeryLongVariableName);
What did you want to happen?
We should be deterministic/consistent about which indentation level is output by the formatter. I think the latter makes the most sense. In our case, we discovered this while using Map.of(), where the former indentation level does make some sense, but I don't think it makes sense to allow that just for Map.of().
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 by reproducing the formatter output with the two long-argument examples from the issue, including the Map.of() case mentioned. Trace the formatter's method-argument indentation behavior and add coverage for the alternating long-argument layout. Done means repeated formatting produces one consistent indentation style.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100