Skip to content

Commit

Permalink
Merge pull request #2116 from jszumski/fix-2115
Browse files Browse the repository at this point in the history
Fixes `redundant_void_return` rule autocorrect when preprocessor macros are present.
  • Loading branch information
marcelofabri authored Mar 28, 2018
2 parents 0982045 + 28989be commit 2b9804c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 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
2 changes: 1 addition & 1 deletion Source/SwiftLintFramework/Rules/ClosureSpacingRule.swift
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public struct ClosureSpacingRule: CorrectableRule, ConfigurationProviderRule, Op
let linesTokens = file.syntaxTokensByLines
let kindsToExclude = SyntaxKind.commentAndStringKinds.map { $0.rawValue }

// find all lines and accurences of open { and closed } braces
// find all lines and occurences of open { and closed } braces
var linesWithBraces = [[NSRange]]()
for eachLine in file.lines {
guard let nsrange = lineContainsBraces(in: eachLine.range, content: nsstring) else {
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 2b9804c

Please sign in to comment.