palantir / palantir/palantir-java-format
Unnecessary line breaks and missed (maybe?) line breaks
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 907
- Forks
- 101
- Avg merge
- 1d 3h
- Merged PRs (30d)
- 19
Description
What happened?
Hello everyone, I am using palantir 2.43.0 in a pretty large codebase through the spotless gradle plugin 6.25.0 and with gradle 8.7. Today I came around this:
private String toString(final String indent) {
return indent
+ name
+ (parameters.isEmpty()
? ""
: "\n" + parameters.stream().map(s -> indent + s).collect(Collectors.joining("\n")))
+ (sons.isEmpty()
? ""
: "\n"
+ sons.stream()
.map(s -> s.toString(indent + " "))
.collect(Collectors.joining("\n")));
}
What did you want to happen?
Maybe something more like this, to avoid unnecessary line breaks.
private String toString(final String indent) {
return indent
+ name
+ (parameters.isEmpty()
? ""
: "\n" + parameters.stream()
.map(s -> indent + s)
.collect(Collectors.joining("\n")))
+ (sons.isEmpty()
? ""
: "\n" + sons.stream()
.map(s -> s.toString(indent + " "))
.collect(Collectors.joining("\n")));
}
I understand that it is a bit specific but I want to understand if it is an error on my side caused by ignorance and misconfiguration or if it is something that palantir can do.
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
Reproduce the formatting of the supplied toString method with palantir 2.43.0 through the Spotless Gradle plugin 6.25.0 on Gradle 8.7, then compare the actual output with the requested output. Trace the formatter behavior responsible for the lambda and stream line breaks; done when the behavior is explained or the output matches the example without an incorrect configuration change.
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
- 38/100