Remove unused code (#4729)
This commit is contained in:
parent
81f1dbfd1b
commit
500f143c7d
|
@ -17,7 +17,7 @@ struct DiscouragedOptionalCollectionRule: ASTRule, OptInRule, ConfigurationProvi
|
|||
func validate(file: SwiftLintFile,
|
||||
kind: SwiftDeclarationKind,
|
||||
dictionary: SourceKittenDictionary) -> [StyleViolation] {
|
||||
let offsets = variableViolations(file: file, kind: kind, dictionary: dictionary) +
|
||||
let offsets = variableViolations(kind: kind, dictionary: dictionary) +
|
||||
functionViolations(file: file, kind: kind, dictionary: dictionary)
|
||||
|
||||
return offsets.map {
|
||||
|
@ -29,9 +29,7 @@ struct DiscouragedOptionalCollectionRule: ASTRule, OptInRule, ConfigurationProvi
|
|||
|
||||
// MARK: - Private
|
||||
|
||||
private func variableViolations(file: SwiftLintFile,
|
||||
kind: SwiftDeclarationKind,
|
||||
dictionary: SourceKittenDictionary) -> [ByteCount] {
|
||||
private func variableViolations(kind: SwiftDeclarationKind, dictionary: SourceKittenDictionary) -> [ByteCount] {
|
||||
guard
|
||||
SwiftDeclarationKind.variableKinds.contains(kind),
|
||||
let offset = dictionary.offset,
|
||||
|
|
|
@ -82,7 +82,7 @@ private struct ExpressibleByCompiler {
|
|||
let initCallNames: Set<String>
|
||||
private let arguments: Set<[String]>
|
||||
|
||||
init(protocolName: String, types: Set<String>, arguments: Set<[String]>) {
|
||||
private init(protocolName: String, types: Set<String>, arguments: Set<[String]>) {
|
||||
self.protocolName = protocolName
|
||||
self.arguments = arguments
|
||||
|
||||
|
|
|
@ -124,8 +124,7 @@ private extension SwiftLintFile {
|
|||
)
|
||||
}
|
||||
|
||||
let contentsNSString = stringView.nsString
|
||||
let unusedImportUsages = rangedAndSortedUnusedImports(of: Array(unusedImports), contents: contentsNSString)
|
||||
let unusedImportUsages = rangedAndSortedUnusedImports(of: Array(unusedImports))
|
||||
.map { ImportUsage.unused(module: $0, range: $1) }
|
||||
|
||||
guard configuration.requireExplicitImports else {
|
||||
|
@ -188,7 +187,7 @@ private extension SwiftLintFile {
|
|||
return (imports: imports, usrFragments: usrFragments)
|
||||
}
|
||||
|
||||
func rangedAndSortedUnusedImports(of unusedImports: [String], contents: NSString) -> [(String, NSRange)] {
|
||||
func rangedAndSortedUnusedImports(of unusedImports: [String]) -> [(String, NSRange)] {
|
||||
return unusedImports
|
||||
.compactMap { module in
|
||||
match(pattern: "^(@\\w+ +)?import +\(module)\\b.*?\n").first.map { (module, $0.0) }
|
||||
|
|
|
@ -50,10 +50,6 @@ struct DeploymentTargetConfiguration: SeverityBasedRuleConfiguration, Equatable
|
|||
self.init(platform: platform, major: major, minor: minor, patch: patch)
|
||||
}
|
||||
|
||||
fileprivate convenience init(platform: Platform, value: Any) throws {
|
||||
try self.init(platform: platform, rawValue: String(describing: value))
|
||||
}
|
||||
|
||||
fileprivate func update(using value: Any) throws {
|
||||
let (major, minor, patch) = try Self.parseVersion(string: String(describing: value))
|
||||
self.major = major
|
||||
|
|
|
@ -57,13 +57,11 @@ struct ModifierOrderRule: ASTRule, OptInRule, ConfigurationProviderRule, Correct
|
|||
|
||||
func correct(file: SwiftLintFile) -> [Correction] {
|
||||
return file.structureDictionary.traverseDepthFirst { subDict in
|
||||
guard let kind = subDict.declarationKind else { return nil }
|
||||
return correct(file: file, kind: kind, dictionary: subDict)
|
||||
guard subDict.declarationKind != nil else { return nil }
|
||||
return correct(file: file, dictionary: subDict)
|
||||
}
|
||||
}
|
||||
private func correct(file: SwiftLintFile,
|
||||
kind: SwiftDeclarationKind,
|
||||
dictionary: SourceKittenDictionary) -> [Correction] {
|
||||
private func correct(file: SwiftLintFile, dictionary: SourceKittenDictionary) -> [Correction] {
|
||||
guard let offset = dictionary.offset else { return [] }
|
||||
let originalContents = file.stringView
|
||||
let violatingRanges = violatingModifiers(dictionary: dictionary)
|
||||
|
|
|
@ -68,8 +68,7 @@ extension Configuration {
|
|||
}
|
||||
let result = await Signposts.record(name: "Configuration.VisitLintableFiles.Visit") {
|
||||
await collected.asyncMap { linters, duplicateFileNames in
|
||||
await visit(linters: linters, visitor: visitor, storage: storage,
|
||||
duplicateFileNames: duplicateFileNames)
|
||||
await visit(linters: linters, visitor: visitor, duplicateFileNames: duplicateFileNames)
|
||||
}
|
||||
}
|
||||
return result.flatMap { $0 }
|
||||
|
@ -182,7 +181,6 @@ extension Configuration {
|
|||
|
||||
private func visit(linters: [CollectedLinter],
|
||||
visitor: LintableFilesVisitor,
|
||||
storage: RuleStorage,
|
||||
duplicateFileNames: Set<String>) async -> [SwiftLintFile] {
|
||||
let counter = CounterActor()
|
||||
let progress = ProgressBar(count: linters.count)
|
||||
|
|
Loading…
Reference in New Issue