Repository navigation
Description
Where: metricshub-eclipse-formatter.xml (the MetricsHub Eclipse formatter profile, applied by formatter-maven-plugin 2.29.0 and checked by formatter:validate).
What happens: when a statement does not fit in 120 columns, the formatter wraps the outermost call first, puts every selector and every argument on a line of its own, and indents each level by two more tabs. A short call with a single long argument ends up spread over many lines. Example from SdrWalker.walk() (PR #222, SdrWalker.java#L149-L157):
skipped
.add(
new SkippedRecord(
recordId,
lastRecordType,
String
.format(
"Names record %04Xh as the next one, which was read already: the walk ends there",
nextRecordId)));skipped.add( and String.format( fit on one line each, yet the selector (.add, .format) goes to its own line and the opening of the call to yet another one.
What should happen: keep a single selector, and a single argument, on the same line as what precedes it whenever it fits, and wrap only the inner arguments that do not fit:
skipped.add(new SkippedRecord(
recordId,
lastRecordType,
String.format(
"Names record %04Xh as the next one, which was read already: the walk ends there",
nextRecordId)));Rule: when there is only one method call in a chain, or only one argument, and it fits on the current line, keep it there instead of breaking the line and indenting.
Settings involved (current values):
| Setting | Value | Effect |
|---|---|---|
wrap_outer_expressions_when_nested |
true |
Wraps the outer expression (skipped.add(...)) before the nested ones, so the outer call breaks although only the inner arguments are too long |
alignment_for_selector_in_method_invocation |
48 (wrap all elements, each on a new line) |
skipped / .add( and String / .format( are split even for a single selector |
alignment_for_arguments_in_method_invocation |
48 |
A single argument (new SkippedRecord(...)) goes to a new line |
alignment_for_arguments_in_allocation_expression |
48 |
Same for new X(...) |
join_wrapped_lines |
false |
Lines wrapped once are never joined back, so changing the other settings alone does not reformat existing code |
A starting point to try: wrap_outer_expressions_when_nested=false, and 16 (wrap where necessary) instead of 48 for the selector alignment, and possibly for the argument alignments too. Run it over the whole code base once with join_wrapped_lines=true so that existing wraps are reflowed. Compare the result on a few typical files (SdrWalker, IpmiClient, IpmiCli, the core coders) before adopting it. These values are untested: check what Eclipse 4.x actually produces with them.
Constraints:
AGENTS.mdsays the profile is byte-identical to jawk's. Changing it here either breaks that, or must be done in both repositories (or in a shared profile) at the same time. Decide which one first.- The reformat touches most Java files: do it in a commit of its own, with no other change, and add that commit to
.git-blame-ignore-revsso thatgit blameskips it. - Checkstyle (
checkstyle.xml, also shared with jawk) must still pass on the reformatted code.
Activity
bertysentry commentedon Oct 20, 2026
Same issue filed for jawk (jawkio/jawk#627, same profile, byte-identical) and winrm-java (MetricsHub/winrm-java#209, its own variant: selectors are already wrapped only where necessary, so only the single-argument and outer-first wrapping apply).
Keep a single selector on the line and join wrapped lines back (#223)
Skip the #223 reformat in git blame, and say how the profile differs …
Merge pull request #234 from MetricsHub/223-formatter-wraps-short-cal…