Skip to content

[platform] Codify naming multi-line conditions - #156

Merged
namolnad merged 2 commits into
mainfrom
platform/named-condition-rule
Aug 14, 2026
Merged

[platform] Codify naming multi-line conditions#156
namolnad merged 2 commits into
mainfrom
platform/named-condition-rule

Conversation

@namolnad

Copy link
Copy Markdown
Owner

Adds a SwiftLint custom rule for the shape we settled on in #155: a condition long enough for SwiftFormat to wrap is long enough to deserve a name.

// flagged
if
    output.isEmpty,
    outputtable is FormatComponent,
    parts.last?.isSeparator == true {

// wanted
let isStrandingSeparator = output.isEmpty && 
if isStrandingSeparator {

Scoped to if only — the multi-line guard … else { return } form appears across five files and reads fine, so it is untouched. No existing file in Sources or Tests matches, so nothing is retroactively broken.

The first commit deliberately violates the rule. SwiftLint isn't installed on my machine, so CI is the only place the rule can be exercised, and a green run would prove only that the YAML parses — not that the regex matches anything. A rule which silently never fires is worse than no rule, since it reads as enforcement. So: lint failing on the probe commit is the passing result, then the probe comes out and lint goes green.

🤖 Generated with Claude Code

Temporary violation, removed in the next commit once CI has shown the rule
catches it. SwiftLint is not installed locally, so CI is the only place the
rule can be exercised — and a green run would otherwise prove only that the
config parses, not that the regex matches anything.
CI showed the rule firing on it, with the intended message:

    RuleProbe.swift:4:1: error: Named Multiline Condition Violation: Name a
    multi-line condition — `let isThing = a && b`, then `if isThing {`

which is what the probe was for. The rule itself is the change.
@namolnad
namolnad merged commit fb61989 into main Aug 14, 2026
3 checks passed
@namolnad
namolnad deleted the platform/named-condition-rule branch August 14, 2026 16:37
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.

1 participant