mirror of
https://github.com/realm/SwiftLint.git
synced 2026-05-07 20:12:49 +00:00
Fix false positives in unused_import rule for constructors defined in transitive modules (#5246)
This commit is contained in:
@@ -24,6 +24,11 @@
|
||||
[jszumski](https://github.com/jszumski)
|
||||
[#5242](https://github.com/realm/SwiftLint/pull/5242)
|
||||
|
||||
* Fix false positive in `unused_import` rule when using a constructor
|
||||
defined in a transitive module.
|
||||
[jszumski](https://github.com/jszumski)
|
||||
[#5246](https://github.com/realm/SwiftLint/pull/5246)
|
||||
|
||||
## 0.53.0: Laundry List
|
||||
|
||||
#### Breaking
|
||||
|
||||
@@ -177,6 +177,11 @@ private extension SwiftLintFile {
|
||||
}
|
||||
|
||||
appendUsedImports(cursorInfo: cursorInfo, usrFragments: &usrFragments)
|
||||
|
||||
// also collect modules from secondary symbol usage if available
|
||||
for secondaryInfo in cursorInfo.secondarySymbols {
|
||||
appendUsedImports(cursorInfo: secondaryInfo, usrFragments: &usrFragments)
|
||||
}
|
||||
}
|
||||
|
||||
return (imports: imports, usrFragments: usrFragments)
|
||||
|
||||
@@ -180,6 +180,12 @@ public struct SourceKittenDictionary {
|
||||
let array = value["key.inheritedtypes"] as? [SourceKitRepresentable] ?? []
|
||||
return array.compactMap { ($0 as? [String: String]).flatMap { $0["key.name"] } }
|
||||
}
|
||||
|
||||
public var secondarySymbols: [SourceKittenDictionary] {
|
||||
let array = value["key.secondary_symbols"] as? [SourceKitRepresentable] ?? []
|
||||
return array.compactMap { $0 as? [String: SourceKitRepresentable] }
|
||||
.map(Self.init)
|
||||
}
|
||||
}
|
||||
|
||||
extension SourceKittenDictionary {
|
||||
|
||||
Reference in New Issue
Block a user