Overview
Never collapse multi-line code into a single line to meet line limits. The fix is always to extract into a named subview/property.
Rule Identifier
no_multiline_collapse
Rationale
Collapsing multi-line code into a single line destroys readability. Line limits exist to encourage extraction, not compression.
Example
// ORIGINAL - triggered skimmable_body warning
@ViewBuilder private var presetButtons: some View {
if !config.presets.isEmpty {
HStack {
ForEach(config.presets.indices, id: \.self) { index in
presetButton(at: index)
}
}
}
}
// ❌ BAD "fix" - cramming code to reduce line count
@ViewBuilder private var presetButtons: some View {
if !config.presets.isEmpty {
HStack {
ForEach(config.presets.indices, id: \.self) { presetButton(at: $0) }
}
}
}
// ✅ GOOD fix - extract complexity
@ViewBuilder private var presetButtons: some View {
if !config.presets.isEmpty {
presetButtonsRow
}
}
private var presetButtonsRow: some View {
HStack {
ForEach(config.presets.indices, id: \.self) { index in
presetButton(at: index)
}
}
}
Detection Challenge
Hard to detect programmatically - this is more of a code review principle. Could potentially detect:
- Lines significantly longer than surrounding code
- Closures with complex expressions crammed onto one line
{ $0.something } patterns that could be expanded
Notes
May be better as skill/guidance than automated rule. Consider implementing as a "suggestion" level rather than warning/error.
Priority
High (as guidance), Medium (as automated rule)
Overview
Never collapse multi-line code into a single line to meet line limits. The fix is always to extract into a named subview/property.
Rule Identifier
no_multiline_collapseRationale
Collapsing multi-line code into a single line destroys readability. Line limits exist to encourage extraction, not compression.
Example
Detection Challenge
Hard to detect programmatically - this is more of a code review principle. Could potentially detect:
{ $0.something }patterns that could be expandedNotes
May be better as skill/guidance than automated rule. Consider implementing as a "suggestion" level rather than warning/error.
Priority
High (as guidance), Medium (as automated rule)