Skip to content

Commit

Permalink
Do not trigger return_value_from_void_function in initializers (#5429)
Browse files Browse the repository at this point in the history
  • Loading branch information
mrbkap authored Jan 19, 2024
1 parent fc2a18e commit 2b6e0ee
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,9 @@
[SimplyDanny](https://github.com/SimplyDanny)
[#3852](https://github.com/realm/SwiftLint/pull/3852)

* Don't trigger the `return_value_from_void_function` warning from initializers.
[mrbkap](https://github.com/mrbkap)

## 0.54.0: Macro-Economic Forces

#### Breaking
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ private extension Syntax {
return node
}

if self.is(ClosureExprSyntax.self) || self.is(VariableDeclSyntax.self) {
if self.is(ClosureExprSyntax.self) || self.is(VariableDeclSyntax.self) || self.is(InitializerDeclSyntax.self) {
return nil
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,17 @@ internal struct ReturnValueFromVoidFunctionRuleExamples {
}
"""),
Example("""
func baz() {
enum Foo {
case bar
init?(arg: String?) {
return nil
}
}
}
""", excludeFromDocumentation: true),
Example("""
func test() {
guard condition else {
return
Expand Down

0 comments on commit 2b6e0ee

Please sign in to comment.