Skip to content

Commit ac93b70

Browse files
committed
Merge pull request #289 from realm/jp-valid-docs-fixes
Fix false positives in ValidDocsRule
2 parents 26dba4e + 4c770d5 commit ac93b70

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717

1818
##### Bug Fixes
1919

20-
* None.
20+
* Fix false positives in ValidDocsRule.
21+
[JP Simard](https://github.com/jpsim)
2122

2223
## 0.5.2: Snuggle™
2324

Source/SwiftLintFramework/Rules/ValidDocsRule.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,13 +92,15 @@ func superfluousOrMissingParameterDocumentation(declaration: String, substructur
9292
}
9393
return (parameter, parameter)
9494
}
95+
let optionallyDocumentedParameterCount = labelsAndParams.filter({ $0.0 == "_" }).count
9596
let commentRange = NSRange(location: 0, length: comment.utf16.count)
96-
let commentParameterMatches = regex("- parameter (.+):")
97+
let commentParameterMatches = regex("- parameter ([^:]+)")
9798
.matchesInString(comment, options: [], range: commentRange)
9899
let commentParameters = commentParameterMatches.map { match in
99100
return (comment as NSString).substringWithRange(match.rangeAtIndex(1))
100101
}
101-
if commentParameters.count != labelsAndParams.count {
102+
if commentParameters.count > labelsAndParams.count ||
103+
labelsAndParams.count - commentParameters.count > optionallyDocumentedParameterCount {
102104
return true
103105
}
104106
return !zip(commentParameters, labelsAndParams).filter {

0 commit comments

Comments
 (0)