Unused import rule transitive dependencies
This PR tries to resolve an issue, when unused import resolved incorrectly, since swiflint doesn't check transitive imports
For example, if we have
import Cocoa
let viewController = NSViewController()
Cocoa module is actually
import AppKit
import Foundation
import CoreData
So this PR actually tries to account transitive_modules configuration to prevent incorrect import removals
Alternative
As an alternative we can try to generate interfaces of all imported modules (once per module) And parse their imports on the top level
So , for example, if we found some missing modules, we'll check if those can be found in the generated interface.
For example,
import SwiftUI
Will allow to use any of the underlying modules
/// Generated SwifTUI interface
import Accessibility
import AppKit
import Combine
import CoreData
import CoreFoundation
import CoreGraphics
import CoreTransferable
import Darwin
import DeveloperToolsSupport
import Foundation
import OSLog
import Observation
import Spatial
import SwiftUICore
import Symbols
import TargetConditionals
import UniformTypeIdentifiers
import _Concurrency
import _StringProcessing
import _SwiftConcurrencyShims
import os
import os.log
import simd
Related Issues: https://github.com/realm/SwiftLint/issues/5167
| 1 Warning | |
|---|---|
| :warning: | This PR may need tests. |
| 17 Messages | |
|---|---|
| :book: | Linting Aerial with this PR took 0.92s vs 0.94s on main (2% faster) |
| :book: | Linting Alamofire with this PR took 1.26s vs 1.27s on main (0% faster) |
| :book: | Linting Brave with this PR took 7.17s vs 7.18s on main (0% faster) |
| :book: | Linting DuckDuckGo with this PR took 5.06s vs 5.07s on main (0% faster) |
| :book: | Linting Firefox with this PR took 10.58s vs 10.61s on main (0% faster) |
| :book: | Linting Kickstarter with this PR took 9.84s vs 9.79s on main (0% slower) |
| :book: | Linting Moya with this PR took 0.53s vs 0.53s on main (0% slower) |
| :book: | Linting NetNewsWire with this PR took 2.62s vs 2.62s on main (0% slower) |
| :book: | Linting Nimble with this PR took 0.77s vs 0.77s on main (0% slower) |
| :book: | Linting PocketCasts with this PR took 8.42s vs 8.37s on main (0% slower) |
| :book: | Linting Quick with this PR took 0.44s vs 0.46s on main (4% faster) |
| :book: | Linting Realm with this PR took 4.51s vs 4.48s on main (0% slower) |
| :book: | Linting Sourcery with this PR took 2.3s vs 2.29s on main (0% slower) |
| :book: | Linting Swift with this PR took 4.48s vs 4.48s on main (0% slower) |
| :book: | Linting VLC with this PR took 1.25s vs 1.25s on main (0% slower) |
| :book: | Linting Wire with this PR took 17.5s vs 17.42s on main (0% slower) |
| :book: | Linting WordPress with this PR took 11.52s vs 11.47s on main (0% slower) |
Generated by :no_entry_sign: Danger