Skip to content

Commit

Permalink
Add rule to omit get clause from computed property declarations when …
Browse files Browse the repository at this point in the history
…unnecessary (airbnb#150)
  • Loading branch information
calda committed Jan 25, 2022
1 parent e4f67dc commit 3fcd5e7
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1899,6 +1899,32 @@ _You can enable the following settings in Xcode by running [this script](resourc

</details>

* <a id='redundant-get'></a>(<a href='#redundant-get'>link</a>) **Omit the `get` clause from a computed property declaration that doesn't also have a `set`, `willSet`, or `didSet` clause.** [![SwiftFormat: redundantGet](https://img.shields.io/badge/SwiftFormat-redundantGet-7B0051.svg)](https://github.com/nicklockwood/SwiftFormat/blob/master/Rules.md#redundantGet)

<details>

```swift
// WRONG
var universe: Universe {
get {
Universe()
}
}

// RIGHT
var universe: Universe {
Universe()
}

// RIGHT
var universe: Universe {
get { multiverseService.current }
set { multiverseService.current = newValue }
}
```

</details>

**[⬆ back to top](#table-of-contents)**

## File Organization
Expand Down
1 change: 1 addition & 0 deletions resources/airbnb.swiftformat
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
--rules redundantSelf
--rules redundantType
--rules redundantPattern
--rules redundantGet
--rules redundantFileprivate
--rules redundantRawValues
--rules sortedImports
Expand Down

0 comments on commit 3fcd5e7

Please sign in to comment.