mirror of
https://github.com/realm/SwiftLint.git
synced 2026-06-06 20:18:40 +00:00
Merge pull request #325 from realm/nn-fix-324
Fix regex for ignoring closure parameter on detecting return value
This commit is contained in:
@@ -14,6 +14,9 @@
|
||||
* AutoCorrect for TrailingNewlineRule only removes at most one line.
|
||||
[John Estropia](https://github.com/JohnEstropia)
|
||||
|
||||
* `valid_docs` did not detect tuple as return value.
|
||||
[Norio Nomura](https://github.com/norio-nomura)
|
||||
[#324](https://github.com/realm/SwiftLint/issues/324)
|
||||
|
||||
## 0.5.5: Magic Drying Fluff Balls™
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ func delcarationReturns(declaration: String, kind: SwiftDeclarationKind) -> Bool
|
||||
if SwiftDeclarationKind.variableKinds().contains(kind) { return true }
|
||||
|
||||
let outsideBraces = NSMutableString(string: declaration)
|
||||
regex("(\\s*->\\s*).*[^(]\\)").replaceMatchesInString(outsideBraces, options: [],
|
||||
regex("(\\s*->\\s*)[^(]*\\)").replaceMatchesInString(outsideBraces, options: [],
|
||||
range: NSRange(location: 0, length: outsideBraces.length), withTemplate: "")
|
||||
|
||||
return outsideBraces.containsString("->")
|
||||
@@ -60,7 +60,7 @@ func commentReturns(comment: String) -> Bool {
|
||||
|
||||
func missingReturnDocumentation(declaration: String, comment: String) -> Bool {
|
||||
let outsideBraces = NSMutableString(string: declaration)
|
||||
regex("(\\s*->\\s*).*[^(]\\)").replaceMatchesInString(outsideBraces, options: [],
|
||||
regex("(\\s*->\\s*)[^(]*\\)").replaceMatchesInString(outsideBraces, options: [],
|
||||
range: NSRange(location: 0, length: outsideBraces.length), withTemplate: "")
|
||||
|
||||
return outsideBraces.containsString("->") && !commentReturns(comment)
|
||||
@@ -135,6 +135,7 @@ public struct ValidDocsRule: Rule {
|
||||
"\n///- parameter param2: this is void too" +
|
||||
"\npublic func no(param: (Void -> Void)?, param2: String->Void) {}",
|
||||
"/// docs👨👩👧👧\n/// - returns: false\npublic func no() -> Bool { return false }",
|
||||
"/// docs\n/// - returns: tuple\npublic func no() -> (Int, Int) {return (1, 2)}",
|
||||
],
|
||||
triggeringExamples: [
|
||||
"/// docs\npublic ↓func a(param: Void) {}\n",
|
||||
|
||||
Reference in New Issue
Block a user