Skip to content

Conversation

@mannylopez
Copy link
Contributor

@mannylopez mannylopez commented Dec 12, 2025

Summary

AddwrapSingleLineBodies rule to

Wrap single-line function, init, subscript, and computed property bodies onto multiple lines.

// WRONG
func foo() { print("bar") }

init() { self.value = 0 }

subscript(index: Int) -> Int { array[index] }

var bar: String { "bar" }

// RIGHT
func foo() {
  print("bar")
}

init() {
  self.value = 0
}

subscript(index: Int) -> Int {
  array[index]
}

var bar: String {
  "bar"
}

Exception: This rule does not affect protocol definitions.

// RIGHT
protocol SpaceshipEngine {
  func engage() -> Bool
  var fuelLevel: Double { get }
}

Reasoning

@mannylopez mannylopez changed the title Add wrapSingleLineDeclarationBodies Add wrapSingleLineBodies Dec 12, 2025
README.md Outdated

```swift
// WRONG
func foo() { print("bar") }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we try to avoid foo / bar in the style guide document, what do you think about updating this to the space theme? Claude should be able to think of a good example

@calda calda force-pushed the manny-lopez--wrapSingleLineDeclarationBodies branch from 9bb3353 to e2de359 Compare December 20, 2025 16:28
@calda calda merged commit 6c09dd5 into master Dec 20, 2025
6 checks passed
@calda calda deleted the manny-lopez--wrapSingleLineDeclarationBodies branch December 20, 2025 16:33
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.

3 participants