diff --git a/CHANGELOG.md b/CHANGELOG.md index 5809c87ab..dad6c92f0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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™ diff --git a/Source/SwiftLintFramework/Rules/ValidDocsRule.swift b/Source/SwiftLintFramework/Rules/ValidDocsRule.swift index c79a56ecc..96ddc312e 100644 --- a/Source/SwiftLintFramework/Rules/ValidDocsRule.swift +++ b/Source/SwiftLintFramework/Rules/ValidDocsRule.swift @@ -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",