Fixed where keyword detection method and CHANGELOG

This commit is contained in:
Almaz Ibragimov
2019-02-14 04:47:24 +03:00
parent 72a18e4aec
commit ee21684e93
2 changed files with 8 additions and 7 deletions
+2 -1
View File
@@ -48,7 +48,8 @@
#### Bug Fixes
* Fix false positives on `no_grouping_extension` rule when using `where` clause.
* Fix false positives on `no_grouping_extension` rule when using `where`
clause.
[Almaz Ibragimov](https://github.com/almazrafi)
* Fix `explicit_type_interface` when used in statements.
@@ -34,7 +34,7 @@ public struct NoGroupingExtensionRule: OptInRule, ConfigurationProviderRule, Aut
return nil
}
guard !hasWhereClause(element: element, file: file) else {
guard !hasWhereClause(dictionary: element.dictionary, file: file) else {
return nil
}
@@ -44,12 +44,12 @@ public struct NoGroupingExtensionRule: OptInRule, ConfigurationProviderRule, Aut
}
}
private func hasWhereClause(element: NamespaceCollector.Element, file: File) -> Bool {
private func hasWhereClause(dictionary: [String: SourceKitRepresentable], file: File) -> Bool {
let contents = file.contents.bridge()
guard let nameOffset = element.dictionary.nameOffset,
let nameLength = element.dictionary.nameLength,
let bodyOffset = element.dictionary.bodyOffset else {
guard let nameOffset = dictionary.nameOffset,
let nameLength = dictionary.nameLength,
let bodyOffset = dictionary.bodyOffset else {
return false
}
@@ -60,6 +60,6 @@ public struct NoGroupingExtensionRule: OptInRule, ConfigurationProviderRule, Aut
return false
}
return (regex(" where ").firstMatch(in: file.contents, options: [], range: range) != nil)
return !file.match(pattern: "\\bwhere\\b", with: [.keyword], range: range).isEmpty
}
}