Skip to content

Commit

Permalink
Add unusedPrivateDeclaration rule (#284)
Browse files Browse the repository at this point in the history
  • Loading branch information
mannylopez authored Aug 7, 2024
1 parent 1d7fa19 commit 633fc25
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
33 changes: 33 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4002,6 +4002,39 @@ _You can enable the following settings in Xcode by running [this script](resourc
```

</details>

* <a id='unused-private-declaration'></a>(<a href='#unused-private-declaration'>link</a>) **Remove unused private and fileprivate properties, functions, and typealiases** [![SwiftFormat: unusedPrivateDeclaration](https://img.shields.io/badge/SwiftFormat-unusedPrivateDeclaration-008489.svg)](https://github.com/nicklockwood/SwiftFormat/blob/master/Rules.md#unusedPrivateDeclaration)

<details>

#### Why?

Improves readability since the code has no effect and should be removed for clarity.

```swift
// WRONG: Includes private declarations that are unused
struct Planet {
var ageInBillionYears: Double {
ageInMillionYears / 1000
}

private var ageInMillionsOfYears: Double
private typealias Dependencies = UniverseBuilderProviding // unused
private var mass: Double // unused
private func distance(to: Planet) { } // unused
}

// RIGHT
struct Planet {
var ageInBillionsOfYears: Double {
ageInMillionYears / 1000
}

private var ageInMillionYears: Double
}
```

</details>

* <a id='remove-empty-extensions'></a>(<a href='#remove-empty-extensions'>link</a>) **Remove empty extensions that define no properties, functions, or conformances.** [![SwiftFormat: emptyExtension](https://img.shields.io/badge/SwiftFormat-emptyExtension-008489.svg)](https://github.com/nicklockwood/SwiftFormat/blob/master/Rules.md#emptyExtension)

Expand Down
1 change: 1 addition & 0 deletions Sources/AirbnbSwiftFormatTool/airbnb.swiftformat
Original file line number Diff line number Diff line change
Expand Up @@ -109,4 +109,5 @@
--rules semicolons
--rules propertyType
--rules blankLinesBetweenChainedFunctions
--rules unusedPrivateDeclaration
--rules emptyExtension

0 comments on commit 633fc25

Please sign in to comment.