Skip to content

Formatter: keep a single selector on the line, join wrapped lines back (#223) - #234

Merged
bertysentry merged 2 commits into
mainfrom
223-formatter-wraps-short-calls-one-element-per-line-keep-a-single-selector-or-argument-on-the-same-line
Oct 26, 2026
Merged

bertysentry merged 2 commits into
mainfrom
223-formatter-wraps-short-calls-one-element-per-line-keep-a-single-selector-or-argument-on-the-same-line

Conversation

@bertysentry

Copy link
Copy Markdown
Contributor

Closes #223.

Profile change (3 settings)

Setting Before After Effect
alignment_for_selector_in_method_invocation 48 (all, one per line) 80 (all except the first, one per line) skipped.add(, String.format(, IpmiClient.builder(host) stay on the line; longer chains still get one selector per line
alignment_for_conditional_expression 32 (compact, first break) 48 (one per line) Needed once lines are joined: otherwise wrapped ?: operands get packed onto overlong lines
join_wrapped_lines false true Existing wraps are reflowed, and the formatter output no longer depends on how the code was wrapped before

The SdrWalker.walk() example of the issue becomes:

					skipped.add(
							new SkippedRecord(
									recordId,
									lastRecordType,
									String.format(
											"Names record %04Xh as the next one, which was read already: the walk ends there",
											nextRecordId)));

What was tried and rejected

  • wrap_outer_expressions_when_nested=false: wraps nested expressions before the outer + concatenation, so long messages break in the middle of a ternary (... + (bridged ? / " through..." : "") + ...). Kept true.
  • Selector 16 (wrap where necessary): packs long StringBuilder.append() / builder chains into dense blocks. 80 keeps them readable.
  • Arguments 80 or 16 instead of 48: 80 leaves the first argument hanging after ( and the others under it; 16 packs arguments. Kept 48.

Not reachable with Eclipse: keeping a single argument on the line (skipped.add(new SkippedRecord() while still putting multiple arguments one per line. The argument alignment applies the same policy whatever the number of arguments, so a lone argument still goes to its own line when the call does not fit.

Commits

  1. 4893b52 profile + whole-tree reformat, no other change (158 files, −1363 lines net); listed in .git-blame-ignore-revs. Merge with a merge commit (not squash/rebase) so that hash stays valid.
  2. .git-blame-ignore-revs and AGENTS.md: the profile is no longer byte-identical to jawk's; AGENTS.md now says how it differs. Formatter wraps short calls one element per line: keep a single selector or argument on the same line jawkio/jawk#627 can adopt the same three settings to make them identical again.

mvn verify site passes (409 tests, formatter validate, Checkstyle, PMD/CPD, SpotBugs).

🤖 Generated with Claude Code

bertysentry and others added 2 commits October 26, 2026 00:13
Formatter profile: a method chain keeps its first selector on the line and
wraps the others one per line (alignment_for_selector_in_method_invocation
48 -> 80), a wrapped conditional puts each operand on its own line
(alignment_for_conditional_expression 32 -> 48), and lines wrapped before
are joined back when they fit (join_wrapped_lines false -> true). Whole-tree
reformat with mvn formatter:format, no other change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…from jawk's

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@bertysentry
bertysentry merged commit 50ad1de into main Oct 26, 2026
4 checks passed
@bertysentry
bertysentry deleted the 223-formatter-wraps-short-calls-one-element-per-line-keep-a-single-selector-or-argument-on-the-same-line branch October 26, 2026 11:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Formatter wraps short calls one element per line: keep a single selector or argument on the same line

1 participant