Skip to content

Commit

Permalink
Fix redundant_void_return rule autocorrect when preprocessor macros…
Browse files Browse the repository at this point in the history
… are present.

Fixes #2115
  • Loading branch information
jszumski committed Mar 28, 2018
1 parent 04666f1 commit 28989be
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@
`unused_closure_parameter`) rules autocorrection inside functions or other
declarations.
[Marcelo Fabri](https://github.com/marcelofabri)

* Fix `redundant_void_return` rule autocorrect when preprocessor macros are present.
[John Szumski](https://github.com/jszumski)
[#2115](https://github.com/realm/SwiftLint/issues/2115)

## 0.25.0: Cleaning the Lint Filter

Expand Down
6 changes: 4 additions & 2 deletions Source/SwiftLintFramework/Rules/RedundantVoidReturnRule.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ public struct RedundantVoidReturnRule: ASTRule, ConfigurationProviderRule, Corre
"func foo()↓ -> Void {}\n": "func foo() {}\n",
"protocol Foo {\n func foo()↓ -> Void\n}\n": "protocol Foo {\n func foo()\n}\n",
"func foo()↓ -> () {}\n": "func foo() {}\n",
"protocol Foo {\n func foo()↓ -> ()\n}\n": "protocol Foo {\n func foo()\n}\n"
"protocol Foo {\n func foo()↓ -> ()\n}\n": "protocol Foo {\n func foo()\n}\n",
"protocol Foo {\n #if true\n func foo()↓ -> Void\n #endif\n}\n":
"protocol Foo {\n #if true\n func foo()\n #endif\n}\n"
]
)

Expand Down Expand Up @@ -87,7 +89,7 @@ public struct RedundantVoidReturnRule: ASTRule, ConfigurationProviderRule, Corre
}

return ranges
}
}.unique
}

private func violationRanges(in file: File) -> [NSRange] {
Expand Down

0 comments on commit 28989be

Please sign in to comment.