-
Notifications
You must be signed in to change notification settings - Fork 653
Replace google-java-format with palantir-java-format #8028
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Replace google-java-format with palantir-java-format #8028
Conversation
Google's formatter is terrible for nested lambda expressions. Palantir's fork fixes that
This PR modifies commands. Please open a corresponding PR in Python Commands and include a link to this PR. |
The palantir formatter broke a little bit. But, since we shouldn't reassign arguments anyway, changing the code to assign to local variables instead is still a win
Map<String, List<Element>> usedNames = Stream.concat( | ||
fieldsToLog.stream(), methodsToLog.stream()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure I like this
.andThen(m_mechanism.m_subsystem.run(() -> { | ||
m_mechanism.m_drive.accept(m_outputVolts.mut_replace( | ||
outputSign * timer.get() * m_config.m_rampRate.in(Volts.per(Second)), Volts)); | ||
m_mechanism.m_log.accept(this); | ||
m_recordState.accept(state); | ||
})) | ||
.finallyDo(() -> { | ||
m_mechanism.m_drive.accept(Volts.of(0)); | ||
m_recordState.accept(State.kNone); | ||
timer.stop(); | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is so much nicer now
new FunctionalCommand(() -> {}, () -> firstHasRun.set(true), interrupted -> {}, () -> { | ||
firstWasPolled.set(true); | ||
return true; | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure I like this, though. Having each lambda argument on its own line was more organized, imo
() -> {}, | ||
() -> {}, | ||
interrupted -> { | ||
if (!interrupted) { | ||
first.incrementAndGet(); | ||
} | ||
}, | ||
() -> true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting how this one kept one line per argument
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is because the lambda in the middle is multiline
FWIW I tried rolling out palantir-java-format at work, and found there's some subtle bugs that are fixed in google-java-format. In particular PJF has poor support for newer Java syntax, sometimes crashing on long text blocks or the ordering of class modifiers. There's open PRs to PJF to fix some of these, but have sat for months with no response. |
google-java-format is terrible for nested lambdas. Palantir's fork fixes that
Most of the formatting changes are from palantir placing variable assignments on the same line as declarations, unlike google's formatter which wanted to place them on different lines