Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds NSError to the list of types in discouraged_direct_init #4508

Merged
merged 1 commit into from
Nov 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@

#### Enhancements

* Adds `NSError` to the list of types in `discouraged_direct_init`.
[jszumski](https://github.com/jszumski)
[#4508](https://github.com/realm/SwiftLint/issues/4508)

* Fix SwiftLint support on Xcode Cloud.
[JagCesar](https://github.com/JagCesar)
[westerlund](https://github.com/westerlund)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,24 @@ public struct DiscouragedDirectInitRule: SwiftSyntaxRule, ConfigurationProviderR
Example("let foo = Bundle(path: \"bar\")"),
Example("let foo = Bundle(identifier: \"bar\")"),
Example("let foo = Bundle.init(path: \"bar\")"),
Example("let foo = Bundle.init(identifier: \"bar\")")
Example("let foo = Bundle.init(identifier: \"bar\")"),
Example("let foo = NSError(domain: \"bar\", code: 0)"),
Example("let foo = NSError.init(domain: \"bar\", code: 0)"),
Example("func testNSError()")
],
triggeringExamples: [
Example("↓UIDevice()"),
Example("↓Bundle()"),
Example("let foo = ↓UIDevice()"),
Example("let foo = ↓Bundle()"),
Example("let foo = bar(bundle: ↓Bundle(), device: ↓UIDevice())"),
Example("let foo = ↓NSError()"),
Example("let foo = bar(bundle: ↓Bundle(), device: ↓UIDevice(), error: ↓NSError())"),
Example("↓UIDevice.init()"),
Example("↓Bundle.init()"),
Example("↓NSError.init()"),
Example("let foo = ↓UIDevice.init()"),
Example("let foo = ↓Bundle.init()"),
Example("let foo = bar(bundle: ↓Bundle.init(), device: ↓UIDevice.init())")
Example("let foo = bar(bundle: ↓Bundle.init(), device: ↓UIDevice.init(), error: ↓NSError.init())")
]
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public struct DiscouragedDirectInitConfiguration: SeverityBasedRuleConfiguration

private let defaultDiscouragedInits = [
"Bundle",
"NSError",
"UIDevice"
]

Expand Down