mirror of
https://github.com/realm/SwiftLint.git
synced 2026-06-06 20:18:40 +00:00
Fixed where keyword detection method and CHANGELOG
This commit is contained in:
+2
-1
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user