diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 7136600b1..37887d79d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -18,7 +18,7 @@ jobs: steps: - uses: actions/checkout@master - uses: jdx/mise-action@v2 - - run: mise run lint + - run: mise run lint-ci macOS: strategy: fail-fast: false diff --git a/.mise/tasks/lint b/.mise/tasks/lint index 6b47c9fe7..fbfd78207 100755 --- a/.mise/tasks/lint +++ b/.mise/tasks/lint @@ -4,5 +4,5 @@ set -euo pipefail cd $MISE_PROJECT_ROOT -swiftformat --quiet --strict . -swiftlint lint --quiet --strict +swiftformat . +swiftlint lint --quiet diff --git a/.mise/tasks/lint-ci b/.mise/tasks/lint-ci new file mode 100755 index 000000000..a7cc42efd --- /dev/null +++ b/.mise/tasks/lint-ci @@ -0,0 +1,8 @@ +#!/bin/bash +# mise description="Lint the project for CI" +set -euo pipefail + +cd $MISE_PROJECT_ROOT + +swiftformat --quiet --strict . +swiftlint lint --quiet --strict diff --git a/Package.swift b/Package.swift index c8ee3b223..3f4c684e5 100644 --- a/Package.swift +++ b/Package.swift @@ -35,6 +35,7 @@ var targets: [PackageDescription.Target] = [ name: "Frontend", dependencies: [ .target(name: "Shared"), + .target(name: "Configuration"), .target(name: "SourceGraph"), .target(name: "PeripheryKit"), .target(name: "ProjectDrivers"), @@ -42,6 +43,25 @@ var targets: [PackageDescription.Target] = [ .product(name: "FilenameMatcher", package: "swift-filename-matcher"), ] ), + .target( + name: "Configuration", + dependencies: [ + .target(name: "Extensions"), + .target(name: "Shared"), + .target(name: "Logger"), + .product(name: "Yams", package: "Yams"), + .product(name: "SystemPackage", package: "swift-system"), + .product(name: "FilenameMatcher", package: "swift-filename-matcher"), + ] + ), + .target( + name: "Extensions", + dependencies: [ + .product(name: "SystemPackage", package: "swift-system"), + .product(name: "FilenameMatcher", package: "swift-filename-matcher"), + ] + ), + .target(name: "Logger"), .target( name: "PeripheryKit", dependencies: [ @@ -80,6 +100,7 @@ var targets: [PackageDescription.Target] = [ .target( name: "SourceGraph", dependencies: [ + .target(name: "Configuration"), .product(name: "SwiftSyntax", package: "swift-syntax"), .target(name: "Shared"), ] @@ -87,7 +108,8 @@ var targets: [PackageDescription.Target] = [ .target( name: "Shared", dependencies: [ - .product(name: "Yams", package: "Yams"), + .target(name: "Extensions"), + .target(name: "Logger"), .product(name: "SystemPackage", package: "swift-system"), .product(name: "FilenameMatcher", package: "swift-filename-matcher"), ] @@ -120,6 +142,7 @@ var targets: [PackageDescription.Target] = [ dependencies: [ .target(name: "TestShared"), .target(name: "PeripheryKit"), + .target(name: "Configuration"), ], exclude: ["AccessibilityProject"] ), diff --git a/Sources/Shared/Configuration.swift b/Sources/Configuration/Configuration.swift similarity index 99% rename from Sources/Shared/Configuration.swift rename to Sources/Configuration/Configuration.swift index 610e72da8..7428078dd 100644 --- a/Sources/Shared/Configuration.swift +++ b/Sources/Configuration/Configuration.swift @@ -1,5 +1,8 @@ +import Extensions import FilenameMatcher import Foundation +import Logger +import Shared import SystemPackage import Yams @@ -38,7 +41,7 @@ public final class Configuration { @Setting(key: "xcode_list_arguments", defaultValue: []) public var xcodeListArguments: [String] - @Setting(key: "retain_assign_only_property_types", defaultValue: [], setter: PropertyTypeSanitizer.sanitize) + @Setting(key: "retain_assign_only_property_types", defaultValue: []) public var retainAssignOnlyPropertyTypes: [String] @Setting(key: "external_encodable_protocols", defaultValue: []) diff --git a/Sources/Shared/OutputFormat.swift b/Sources/Configuration/OutputFormat.swift similarity index 100% rename from Sources/Shared/OutputFormat.swift rename to Sources/Configuration/OutputFormat.swift diff --git a/Sources/Shared/Extensions/Array+Extension.swift b/Sources/Extensions/Array+Extension.swift similarity index 100% rename from Sources/Shared/Extensions/Array+Extension.swift rename to Sources/Extensions/Array+Extension.swift diff --git a/Sources/Shared/Extensions/Collection+Extension.swift b/Sources/Extensions/Collection+Extension.swift similarity index 100% rename from Sources/Shared/Extensions/Collection+Extension.swift rename to Sources/Extensions/Collection+Extension.swift diff --git a/Sources/Shared/Extensions/FilePath+Extension.swift b/Sources/Extensions/FilePath+Extension.swift similarity index 100% rename from Sources/Shared/Extensions/FilePath+Extension.swift rename to Sources/Extensions/FilePath+Extension.swift diff --git a/Sources/Shared/Extensions/FilePath+Glob.swift b/Sources/Extensions/FilePath+Glob.swift similarity index 98% rename from Sources/Shared/Extensions/FilePath+Glob.swift rename to Sources/Extensions/FilePath+Glob.swift index 2d32d8032..bdc0b52d2 100644 --- a/Sources/Shared/Extensions/FilePath+Glob.swift +++ b/Sources/Extensions/FilePath+Glob.swift @@ -69,7 +69,7 @@ private class Glob { let firstPart = parts.removeFirst() var lastPart = parts.joined(separator: "**") - var directories: [URL] = if FileManager.default.fileExists(atPath: firstPart) { + let directories: [URL] = if FileManager.default.fileExists(atPath: firstPart) { exploreDirectories(url: URL(fileURLWithPath: firstPart)) } else { [] diff --git a/Sources/Shared/Extensions/FilenameMatcher+Extension.swift b/Sources/Extensions/FilenameMatcher+Extension.swift similarity index 100% rename from Sources/Shared/Extensions/FilenameMatcher+Extension.swift rename to Sources/Extensions/FilenameMatcher+Extension.swift diff --git a/Sources/Shared/Extensions/Sequence+Extension.swift b/Sources/Extensions/Sequence+Extension.swift similarity index 100% rename from Sources/Shared/Extensions/Sequence+Extension.swift rename to Sources/Extensions/Sequence+Extension.swift diff --git a/Sources/Shared/Extensions/Set+Extension.swift b/Sources/Extensions/Set+Extension.swift similarity index 100% rename from Sources/Shared/Extensions/Set+Extension.swift rename to Sources/Extensions/Set+Extension.swift diff --git a/Sources/Shared/Extensions/String+Extension.swift b/Sources/Extensions/String+Extension.swift similarity index 100% rename from Sources/Shared/Extensions/String+Extension.swift rename to Sources/Extensions/String+Extension.swift diff --git a/Sources/Shared/Extensions/String+Version.swift b/Sources/Extensions/String+Version.swift similarity index 100% rename from Sources/Shared/Extensions/String+Version.swift rename to Sources/Extensions/String+Version.swift diff --git a/Sources/Frontend/Commands/CheckUpdateCommand.swift b/Sources/Frontend/Commands/CheckUpdateCommand.swift index cf1329552..83c9b73ff 100644 --- a/Sources/Frontend/Commands/CheckUpdateCommand.swift +++ b/Sources/Frontend/Commands/CheckUpdateCommand.swift @@ -1,6 +1,7 @@ import ArgumentParser +import Configuration import Foundation -import Shared +import Logger struct CheckUpdateCommand: FrontendCommand { static let configuration = CommandConfiguration( diff --git a/Sources/Frontend/Commands/ClearCacheCommand.swift b/Sources/Frontend/Commands/ClearCacheCommand.swift index 9897fdda4..8a45db926 100644 --- a/Sources/Frontend/Commands/ClearCacheCommand.swift +++ b/Sources/Frontend/Commands/ClearCacheCommand.swift @@ -1,5 +1,7 @@ import ArgumentParser +import Configuration import Foundation +import Logger import Shared struct ClearCacheCommand: FrontendCommand { diff --git a/Sources/Frontend/Commands/FrontendCommand.swift b/Sources/Frontend/Commands/FrontendCommand.swift index 872d120eb..b7d112791 100644 --- a/Sources/Frontend/Commands/FrontendCommand.swift +++ b/Sources/Frontend/Commands/FrontendCommand.swift @@ -1,5 +1,5 @@ import ArgumentParser -import Shared +import Logger protocol FrontendCommand: ParsableCommand {} extension FrontendCommand { diff --git a/Sources/Frontend/Commands/ScanBehavior.swift b/Sources/Frontend/Commands/ScanBehavior.swift deleted file mode 100644 index 9befb17f8..000000000 --- a/Sources/Frontend/Commands/ScanBehavior.swift +++ /dev/null @@ -1,100 +0,0 @@ -import Foundation -import PeripheryKit -import Shared -import SystemPackage - -final class ScanBehavior { - private let configuration: Configuration - private let logger: Logger - private let shell: Shell - private let swiftVersion: SwiftVersion - - required init(configuration: Configuration, logger: Logger, shell: Shell, swiftVersion: SwiftVersion) { - self.configuration = configuration - self.logger = logger - self.shell = shell - self.swiftVersion = swiftVersion - } - - func setup(_ configPath: FilePath?) -> Result { - do { - try configuration.load(from: configPath, logger: logger) - } catch let error as PeripheryError { - return .failure(error) - } catch { - return .failure(.underlyingError(error)) - } - - return .success(()) - } - - func main(_ block: (Project) throws -> [ScanResult]) -> Result { - logger.contextualized(with: "version").debug(PeripheryVersion) - - let project: Project - - do { - logger.debug(swiftVersion.fullVersion) - try swiftVersion.validateVersion() - - if configuration.guidedSetup { - project = try GuidedSetup(configuration: configuration, shell: shell, logger: logger).perform() - } else { - project = try Project(configuration: configuration, shell: shell, logger: logger) - } - } catch let error as PeripheryError { - return .failure(error) - } catch { - return .failure(.underlyingError(error)) - } - - let updateChecker = UpdateChecker(logger: logger, configuration: configuration) - updateChecker.run() - - let results: [ScanResult] - - do { - results = try block(project) - - let interval = logger.beginInterval("result:output") - var baseline: Baseline? - - if let baselinePath = configuration.baseline { - let data = try Data(contentsOf: baselinePath.url) - baseline = try JSONDecoder().decode(Baseline.self, from: data) - } - - let filteredResults = try OutputDeclarationFilter(configuration: configuration, logger: logger).filter(results, with: baseline) - - if let baselinePath = configuration.writeBaseline { - let usrs = filteredResults - .flatMapSet { $0.usrs } - .union(baseline?.usrs ?? []) - let baseline = Baseline.v1(usrs: usrs.sorted()) - let data = try JSONEncoder().encode(baseline) - try data.write(to: baselinePath.url) - } - - let output = try configuration.outputFormat.formatter.init(configuration: configuration).format(filteredResults) - - if configuration.outputFormat.supportsAuxiliaryOutput { - logger.info("", canQuiet: true) - } - - logger.info(output, canQuiet: false) - logger.endInterval(interval) - - updateChecker.notifyIfAvailable() - - if !filteredResults.isEmpty, configuration.strict { - throw PeripheryError.foundIssues(count: filteredResults.count) - } - } catch let error as PeripheryError { - return .failure(error) - } catch { - return .failure(.underlyingError(error)) - } - - return .success(()) - } -} diff --git a/Sources/Frontend/Commands/ScanCommand.swift b/Sources/Frontend/Commands/ScanCommand.swift index cee0171ba..f0468b888 100644 --- a/Sources/Frontend/Commands/ScanCommand.swift +++ b/Sources/Frontend/Commands/ScanCommand.swift @@ -1,5 +1,8 @@ import ArgumentParser +import Configuration import Foundation +import Logger +import PeripheryKit import Shared import SystemPackage @@ -135,14 +138,13 @@ struct ScanCommand: FrontendCommand { private static let defaultConfiguration = Configuration() func run() throws { + let logger = Logger(quiet: quiet, verbose: verbose) + logger.contextualized(with: "version").debug(PeripheryVersion) + let configuration = Configuration() - let logger = Logger(configuration: configuration) - let shell = Shell(logger: logger) - let swiftVersion = SwiftVersion(shell: shell) - let scanBehavior = ScanBehavior(configuration: configuration, logger: logger, shell: shell, swiftVersion: swiftVersion) if !setup { - try scanBehavior.setup(config).get() + try configuration.load(from: config, logger: logger) } configuration.guidedSetup = setup @@ -186,13 +188,59 @@ struct ScanCommand: FrontendCommand { configuration.apply(\.$bazel, bazel) configuration.apply(\.$bazelFilter, bazelFilter) - try scanBehavior.main { project in - try Scan( - configuration: configuration, - logger: logger, - swiftVersion: swiftVersion - ).perform(project: project) - }.get() + let shell = Shell(logger: logger) + let swiftVersion = SwiftVersion(shell: shell) + logger.debug(swiftVersion.fullVersion) + try swiftVersion.validateVersion() + + let project: Project = if configuration.guidedSetup { + try GuidedSetup(configuration: configuration, shell: shell, logger: logger).perform() + } else { + try Project(configuration: configuration, shell: shell, logger: logger) + } + + let updateChecker = UpdateChecker(logger: logger, configuration: configuration) + updateChecker.run() + + let results = try Scan( + configuration: configuration, + logger: logger, + swiftVersion: swiftVersion + ).perform(project: project) + + let interval = logger.beginInterval("result:output") + var baseline: Baseline? + + if let baselinePath = configuration.baseline { + let data = try Data(contentsOf: baselinePath.url) + baseline = try JSONDecoder().decode(Baseline.self, from: data) + } + + let filteredResults = try OutputDeclarationFilter(configuration: configuration, logger: logger).filter(results, with: baseline) + + if let baselinePath = configuration.writeBaseline { + let usrs = filteredResults + .flatMapSet { $0.usrs } + .union(baseline?.usrs ?? []) + let baseline = Baseline.v1(usrs: usrs.sorted()) + let data = try JSONEncoder().encode(baseline) + try data.write(to: baselinePath.url) + } + + let output = try configuration.outputFormat.formatter.init(configuration: configuration).format(filteredResults) + + if configuration.outputFormat.supportsAuxiliaryOutput { + logger.info("", canQuiet: true) + } + + logger.info(output, canQuiet: false) + logger.endInterval(interval) + + updateChecker.notifyIfAvailable() + + if !filteredResults.isEmpty, configuration.strict { + throw PeripheryError.foundIssues(count: filteredResults.count) + } } } diff --git a/Sources/Frontend/CommonSetupGuide.swift b/Sources/Frontend/CommonSetupGuide.swift index 8d8aa14fb..8fb491bca 100644 --- a/Sources/Frontend/CommonSetupGuide.swift +++ b/Sources/Frontend/CommonSetupGuide.swift @@ -1,4 +1,6 @@ +import Configuration import Foundation +import Logger import Shared final class CommonSetupGuide: SetupGuideHelpers { diff --git a/Sources/Frontend/GuidedSetup.swift b/Sources/Frontend/GuidedSetup.swift index edce4b8e5..7a1ead2e1 100644 --- a/Sources/Frontend/GuidedSetup.swift +++ b/Sources/Frontend/GuidedSetup.swift @@ -1,4 +1,6 @@ +import Configuration import Foundation +import Logger import Shared #if canImport(XcodeSupport) diff --git a/Sources/Frontend/Logger+Extension.swift b/Sources/Frontend/Logger+Extension.swift new file mode 100644 index 000000000..727fa395a --- /dev/null +++ b/Sources/Frontend/Logger+Extension.swift @@ -0,0 +1,9 @@ +import Configuration +import Logger + +public extension Logger { + @inlinable + convenience init(configuration: Configuration) { + self.init(quiet: configuration.quiet, verbose: configuration.verbose) + } +} diff --git a/Sources/Frontend/Project.swift b/Sources/Frontend/Project.swift index ca1924635..1f4ba1b0b 100644 --- a/Sources/Frontend/Project.swift +++ b/Sources/Frontend/Project.swift @@ -1,4 +1,6 @@ +import Configuration import Foundation +import Logger import ProjectDrivers import Shared import SystemPackage diff --git a/Sources/Frontend/SPMProjectSetupGuide.swift b/Sources/Frontend/SPMProjectSetupGuide.swift index 8d2e7c5ec..e7ee15577 100644 --- a/Sources/Frontend/SPMProjectSetupGuide.swift +++ b/Sources/Frontend/SPMProjectSetupGuide.swift @@ -1,4 +1,5 @@ import Foundation +import ProjectDrivers import Shared import SystemPackage diff --git a/Sources/Frontend/Scan.swift b/Sources/Frontend/Scan.swift index 2a40a52b6..cfeee64f8 100644 --- a/Sources/Frontend/Scan.swift +++ b/Sources/Frontend/Scan.swift @@ -1,5 +1,7 @@ +import Configuration import Foundation import Indexer +import Logger import PeripheryKit import ProjectDrivers import Shared diff --git a/Sources/Frontend/UpdateChecker.swift b/Sources/Frontend/UpdateChecker.swift index a8629d61f..9f74f0874 100644 --- a/Sources/Frontend/UpdateChecker.swift +++ b/Sources/Frontend/UpdateChecker.swift @@ -1,4 +1,6 @@ +import Configuration import Foundation +import Logger import Shared #if canImport(FoundationNetworking) diff --git a/Sources/Frontend/main.swift b/Sources/Frontend/main.swift index 793f32931..afa301355 100644 --- a/Sources/Frontend/main.swift +++ b/Sources/Frontend/main.swift @@ -1,5 +1,6 @@ import ArgumentParser import Foundation +import Logger import Shared Logger.configureBuffering() @@ -17,19 +18,24 @@ struct PeripheryCommand: FrontendCommand { } signal(SIGINT) { _ in - let logger = Logger(configuration: Configuration()) + let logger = Logger() logger.warn( "Termination can result in a corrupt index. Try the '--clean-build' flag if you get erroneous results such as false-positives and incorrect source file locations.", newlinePrefix: true // Print a newline after ^C ) - let shell = Shell(logger: logger) - shell.interruptRunning() + ShellProcessStore.shared.interruptRunning() exit(0) } do { var command = try PeripheryCommand.parseAsRoot() - try command.run() + do { + try command.run() + } catch let error as PeripheryError { + throw error + } catch { + throw PeripheryError.underlyingError(error) + } } catch { PeripheryCommand.exit(withError: error) } diff --git a/Sources/Indexer/IndexPipeline.swift b/Sources/Indexer/IndexPipeline.swift index c47d0313e..25fabafe4 100644 --- a/Sources/Indexer/IndexPipeline.swift +++ b/Sources/Indexer/IndexPipeline.swift @@ -1,5 +1,6 @@ +import Configuration import Foundation -import Shared +import Logger import SourceGraph public struct IndexPipeline { diff --git a/Sources/Indexer/Indexer.swift b/Sources/Indexer/Indexer.swift index 8bd993b43..2cc9a454b 100644 --- a/Sources/Indexer/Indexer.swift +++ b/Sources/Indexer/Indexer.swift @@ -1,6 +1,6 @@ +import Configuration import FilenameMatcher import Foundation -import Shared import SourceGraph import SystemPackage diff --git a/Sources/Indexer/InfoPlistIndexer.swift b/Sources/Indexer/InfoPlistIndexer.swift index 0ebeffe23..28bfaffd1 100644 --- a/Sources/Indexer/InfoPlistIndexer.swift +++ b/Sources/Indexer/InfoPlistIndexer.swift @@ -1,3 +1,5 @@ +import Configuration +import Logger import Shared import SourceGraph import SystemPackage diff --git a/Sources/Indexer/InfoPlistParser.swift b/Sources/Indexer/InfoPlistParser.swift index a6dac4d7e..e0cd21d0c 100644 --- a/Sources/Indexer/InfoPlistParser.swift +++ b/Sources/Indexer/InfoPlistParser.swift @@ -1,6 +1,5 @@ import AEXML import Foundation -import Shared import SourceGraph import SystemPackage diff --git a/Sources/Indexer/SourceFileCollector.swift b/Sources/Indexer/SourceFileCollector.swift index 85c008f3d..8df3b33c4 100644 --- a/Sources/Indexer/SourceFileCollector.swift +++ b/Sources/Indexer/SourceFileCollector.swift @@ -1,4 +1,6 @@ +import Configuration import Foundation +import Logger import Shared import SourceGraph import SwiftIndexStore diff --git a/Sources/Indexer/SwiftIndexer.swift b/Sources/Indexer/SwiftIndexer.swift index b40dd8aa9..7adb442ff 100644 --- a/Sources/Indexer/SwiftIndexer.swift +++ b/Sources/Indexer/SwiftIndexer.swift @@ -1,4 +1,6 @@ +import Configuration import Foundation +import Logger import Shared import SourceGraph import SwiftIndexStore diff --git a/Sources/Indexer/XCDataModelIndexer.swift b/Sources/Indexer/XCDataModelIndexer.swift index 25b4c46c7..57b1399a2 100644 --- a/Sources/Indexer/XCDataModelIndexer.swift +++ b/Sources/Indexer/XCDataModelIndexer.swift @@ -1,3 +1,5 @@ +import Configuration +import Logger import Shared import SourceGraph import SystemPackage diff --git a/Sources/Indexer/XCMappingModelIndexer.swift b/Sources/Indexer/XCMappingModelIndexer.swift index 2439e33a6..8e72f0cf1 100644 --- a/Sources/Indexer/XCMappingModelIndexer.swift +++ b/Sources/Indexer/XCMappingModelIndexer.swift @@ -1,3 +1,5 @@ +import Configuration +import Logger import Shared import SourceGraph import SystemPackage diff --git a/Sources/Indexer/XibIndexer.swift b/Sources/Indexer/XibIndexer.swift index 5d7b34e70..04e2d2d12 100644 --- a/Sources/Indexer/XibIndexer.swift +++ b/Sources/Indexer/XibIndexer.swift @@ -1,3 +1,5 @@ +import Configuration +import Logger import Shared import SourceGraph import SystemPackage diff --git a/Sources/Shared/Logger.swift b/Sources/Logger/Logger.swift similarity index 92% rename from Sources/Shared/Logger.swift rename to Sources/Logger/Logger.swift index f6fc4d510..ed664d6fe 100644 --- a/Sources/Shared/Logger.swift +++ b/Sources/Logger/Logger.swift @@ -49,16 +49,18 @@ public final class Logger { } } - @usableFromInline let configuration: Configuration @usableFromInline let outputQueue: DispatchQueue + @usableFromInline let quiet: Bool + @usableFromInline let verbose: Bool #if canImport(os) @usableFromInline let signposter = OSSignposter() #endif @inlinable - public required init(configuration: Configuration) { - self.configuration = configuration + public required init(quiet: Bool = false, verbose: Bool = false) { + self.quiet = quiet + self.verbose = verbose outputQueue = DispatchQueue(label: "Logger.outputQueue") } @@ -69,19 +71,19 @@ public final class Logger { @inlinable public func info(_ text: String, canQuiet: Bool = true) { - guard !(configuration.quiet && canQuiet) else { return } + guard !(quiet && canQuiet) else { return } log(text, output: stdout) } @inlinable public func debug(_ text: String) { - guard configuration.verbose else { return } + guard verbose else { return } log(text, output: stdout) } @inlinable public func warn(_ text: String, newlinePrefix: Bool = false) { - guard !configuration.quiet else { return } + guard !quiet else { return } if newlinePrefix { log("", output: stderr) } diff --git a/Sources/PeripheryKit/Results/CheckstyleFormatter.swift b/Sources/PeripheryKit/Results/CheckstyleFormatter.swift index 706f76ed6..b334abfa3 100644 --- a/Sources/PeripheryKit/Results/CheckstyleFormatter.swift +++ b/Sources/PeripheryKit/Results/CheckstyleFormatter.swift @@ -1,5 +1,5 @@ +import Configuration import Foundation -import Shared import SourceGraph import SystemPackage diff --git a/Sources/PeripheryKit/Results/CodeClimateFormatter.swift b/Sources/PeripheryKit/Results/CodeClimateFormatter.swift index c3400ce79..7fcd54acc 100644 --- a/Sources/PeripheryKit/Results/CodeClimateFormatter.swift +++ b/Sources/PeripheryKit/Results/CodeClimateFormatter.swift @@ -1,5 +1,5 @@ +import Configuration import Foundation -import Shared import SystemPackage final class CodeClimateFormatter: OutputFormatter { diff --git a/Sources/PeripheryKit/Results/CsvFormatter.swift b/Sources/PeripheryKit/Results/CsvFormatter.swift index 07d082279..93fdee6af 100644 --- a/Sources/PeripheryKit/Results/CsvFormatter.swift +++ b/Sources/PeripheryKit/Results/CsvFormatter.swift @@ -1,5 +1,5 @@ +import Configuration import Foundation -import Shared import SourceGraph import SystemPackage diff --git a/Sources/PeripheryKit/Results/GitHubActionsFormatter.swift b/Sources/PeripheryKit/Results/GitHubActionsFormatter.swift index b20af84d7..f855b0a29 100644 --- a/Sources/PeripheryKit/Results/GitHubActionsFormatter.swift +++ b/Sources/PeripheryKit/Results/GitHubActionsFormatter.swift @@ -1,3 +1,4 @@ +import Configuration import Foundation import Shared import SourceGraph diff --git a/Sources/PeripheryKit/Results/JsonFormatter.swift b/Sources/PeripheryKit/Results/JsonFormatter.swift index 5e802d5a5..9bce7491b 100644 --- a/Sources/PeripheryKit/Results/JsonFormatter.swift +++ b/Sources/PeripheryKit/Results/JsonFormatter.swift @@ -1,5 +1,5 @@ +import Configuration import Foundation -import Shared import SystemPackage final class JsonFormatter: OutputFormatter { diff --git a/Sources/PeripheryKit/Results/OutputDeclarationFilter.swift b/Sources/PeripheryKit/Results/OutputDeclarationFilter.swift index bce83a782..e7b936491 100644 --- a/Sources/PeripheryKit/Results/OutputDeclarationFilter.swift +++ b/Sources/PeripheryKit/Results/OutputDeclarationFilter.swift @@ -1,6 +1,7 @@ +import Configuration import FilenameMatcher import Foundation -import Shared +import Logger import SystemPackage public final class OutputDeclarationFilter { diff --git a/Sources/PeripheryKit/Results/OutputFormatter.swift b/Sources/PeripheryKit/Results/OutputFormatter.swift index d388f9c4f..3403060e4 100644 --- a/Sources/PeripheryKit/Results/OutputFormatter.swift +++ b/Sources/PeripheryKit/Results/OutputFormatter.swift @@ -1,5 +1,6 @@ +import Configuration import Foundation -import Shared +import Logger import SourceGraph import SystemPackage diff --git a/Sources/PeripheryKit/Results/XcodeFormatter.swift b/Sources/PeripheryKit/Results/XcodeFormatter.swift index 674d1fcdd..0bed933b7 100644 --- a/Sources/PeripheryKit/Results/XcodeFormatter.swift +++ b/Sources/PeripheryKit/Results/XcodeFormatter.swift @@ -1,5 +1,6 @@ +import Configuration import Foundation -import Shared +import Logger import SourceGraph import SystemPackage diff --git a/Sources/ProjectDrivers/BazelProjectDriver.swift b/Sources/ProjectDrivers/BazelProjectDriver.swift index 5d212a66c..640eab1de 100644 --- a/Sources/ProjectDrivers/BazelProjectDriver.swift +++ b/Sources/ProjectDrivers/BazelProjectDriver.swift @@ -1,4 +1,6 @@ +import Configuration import Foundation +import Logger import Shared import SystemPackage diff --git a/Sources/ProjectDrivers/GenericProjectDriver.swift b/Sources/ProjectDrivers/GenericProjectDriver.swift index 4b2f1a883..6807e3643 100644 --- a/Sources/ProjectDrivers/GenericProjectDriver.swift +++ b/Sources/ProjectDrivers/GenericProjectDriver.swift @@ -1,5 +1,7 @@ +import Configuration import Foundation import Indexer +import Logger import Shared import SwiftIndexStore import SystemPackage diff --git a/Sources/ProjectDrivers/ProjectDriver.swift b/Sources/ProjectDrivers/ProjectDriver.swift index 7a439ea96..0c4acc4e6 100644 --- a/Sources/ProjectDrivers/ProjectDriver.swift +++ b/Sources/ProjectDrivers/ProjectDriver.swift @@ -1,6 +1,6 @@ import Foundation import Indexer -import Shared +import Logger import SwiftIndexStore public protocol ProjectDriver { diff --git a/Sources/Shared/SPM.swift b/Sources/ProjectDrivers/SPM.swift similarity index 96% rename from Sources/Shared/SPM.swift rename to Sources/ProjectDrivers/SPM.swift index a15c0b172..3afb262fe 100644 --- a/Sources/Shared/SPM.swift +++ b/Sources/ProjectDrivers/SPM.swift @@ -1,4 +1,8 @@ +import Configuration +import Extensions import Foundation +import Logger +import Shared import SystemPackage public enum SPM { diff --git a/Sources/ProjectDrivers/SPMProjectDriver.swift b/Sources/ProjectDrivers/SPMProjectDriver.swift index 520831699..c2508a8bc 100644 --- a/Sources/ProjectDrivers/SPMProjectDriver.swift +++ b/Sources/ProjectDrivers/SPMProjectDriver.swift @@ -1,5 +1,7 @@ +import Configuration import Foundation import Indexer +import Logger import Shared import SwiftIndexStore import SystemPackage diff --git a/Sources/ProjectDrivers/XcodeProjectDriver.swift b/Sources/ProjectDrivers/XcodeProjectDriver.swift index 77a6ca2d3..e46e71eab 100644 --- a/Sources/ProjectDrivers/XcodeProjectDriver.swift +++ b/Sources/ProjectDrivers/XcodeProjectDriver.swift @@ -1,6 +1,8 @@ #if os(macOS) + import Configuration import Foundation import Indexer + import Logger import Shared import SourceGraph import SystemPackage diff --git a/Sources/Shared/PropertyTypeSanitizer.swift b/Sources/Shared/PropertyTypeSanitizer.swift index d87e50419..01f2aaae9 100644 --- a/Sources/Shared/PropertyTypeSanitizer.swift +++ b/Sources/Shared/PropertyTypeSanitizer.swift @@ -1,12 +1,7 @@ +import Extensions import Foundation public enum PropertyTypeSanitizer { - @inlinable - public static func sanitize(_ value: Any) -> [String]? { - guard let typedValue = value as? [String] else { return nil } - return typedValue.map { sanitize($0) } - } - @inlinable public static func sanitize(_ type: String) -> String { type.trimmed.trimmingCharacters(in: .init(["?", "!"])) diff --git a/Sources/Shared/SetupGuide.swift b/Sources/Shared/SetupGuide.swift index 21e43b561..08a471001 100644 --- a/Sources/Shared/SetupGuide.swift +++ b/Sources/Shared/SetupGuide.swift @@ -1,4 +1,5 @@ import Foundation +import Logger public protocol SetupGuide { func perform() throws -> ProjectKind diff --git a/Sources/Shared/Shell.swift b/Sources/Shared/Shell.swift index d2c7339e4..ae27c4ea1 100644 --- a/Sources/Shared/Shell.swift +++ b/Sources/Shared/Shell.swift @@ -1,9 +1,31 @@ import Foundation +import Logger -open class Shell { - private var tasks: Set = [] - private var tasksQueue = DispatchQueue(label: "Shell.tasksQueue") +public class ShellProcessStore { + public static let shared = ShellProcessStore() + + private var processes: Set = [] + private let lock = UnfairLock() + + public func interruptRunning() { + lock.perform { + for process in processes { + process.interrupt() + process.waitUntilExit() + } + } + } + + func add(_ process: Process) { + lock.perform { _ = processes.insert(process) } + } + func remove(_ process: Process) { + lock.perform { _ = processes.remove(process) } + } +} + +open class Shell { private let environment: [String: String] private let logger: ContextualLogger @@ -16,15 +38,6 @@ open class Shell { self.logger = logger.contextualized(with: "shell") } - public func interruptRunning() { - tasksQueue.sync { - for task in tasks { - task.interrupt() - task.waitUntilExit() - } - } - } - lazy var pristineEnvironment: [String: String] = { let shell = environment["SHELL"] ?? "/bin/bash" guard let pristineEnv = try? exec([shell, "-lc", "env"], environment: [:]).1 else { @@ -98,23 +111,23 @@ open class Shell { newArgs = args } - let task = Process() - task.launchPath = launchPath - task.environment = environment - task.arguments = newArgs + let process = Process() + process.launchPath = launchPath + process.environment = environment + process.arguments = newArgs logger.debug("\(launchPath) \(newArgs.joined(separator: " "))") - tasksQueue.sync { _ = tasks.insert(task) } + ShellProcessStore.shared.add(process) var outputPipe: Pipe? if captureOutput { outputPipe = Pipe() - task.standardOutput = outputPipe - task.standardError = stderr ? outputPipe : nil + process.standardOutput = outputPipe + process.standardError = stderr ? outputPipe : nil } - task.launch() + process.launch() var output = "" @@ -122,7 +135,7 @@ open class Shell { let outputData = try outputPipe.fileHandleForReading.readToEnd() { guard let str = String(data: outputData, encoding: .utf8) else { - tasksQueue.sync { _ = tasks.remove(task) } + ShellProcessStore.shared.remove(process) throw PeripheryError.shellOutputEncodingFailed( cmd: launchPath, args: newArgs, @@ -132,8 +145,8 @@ open class Shell { output = str } - task.waitUntilExit() - tasksQueue.sync { _ = tasks.remove(task) } - return (task.terminationStatus, output) + process.waitUntilExit() + ShellProcessStore.shared.remove(process) + return (process.terminationStatus, output) } } diff --git a/Sources/Shared/SwiftVersion.swift b/Sources/Shared/SwiftVersion.swift index 110f95893..974502cb1 100644 --- a/Sources/Shared/SwiftVersion.swift +++ b/Sources/Shared/SwiftVersion.swift @@ -1,3 +1,4 @@ +import Extensions import Foundation public struct SwiftVersion { diff --git a/Sources/Shared/SwiftVersionParser.swift b/Sources/Shared/SwiftVersionParser.swift index ad484c00e..c9d12d840 100644 --- a/Sources/Shared/SwiftVersionParser.swift +++ b/Sources/Shared/SwiftVersionParser.swift @@ -1,3 +1,4 @@ +import Extensions import Foundation enum SwiftVersionParser { diff --git a/Sources/SourceGraph/Mutators/AccessibilityCascader.swift b/Sources/SourceGraph/Mutators/AccessibilityCascader.swift index bb8feed12..de8acea12 100644 --- a/Sources/SourceGraph/Mutators/AccessibilityCascader.swift +++ b/Sources/SourceGraph/Mutators/AccessibilityCascader.swift @@ -1,3 +1,4 @@ +import Configuration import Foundation import Shared diff --git a/Sources/SourceGraph/Mutators/AncestralReferenceEliminator.swift b/Sources/SourceGraph/Mutators/AncestralReferenceEliminator.swift index a4ffd7eeb..bd50674e3 100644 --- a/Sources/SourceGraph/Mutators/AncestralReferenceEliminator.swift +++ b/Sources/SourceGraph/Mutators/AncestralReferenceEliminator.swift @@ -1,3 +1,4 @@ +import Configuration import Foundation import Shared diff --git a/Sources/SourceGraph/Mutators/AssetReferenceRetainer.swift b/Sources/SourceGraph/Mutators/AssetReferenceRetainer.swift index 08237e0e5..4b1d6d61f 100644 --- a/Sources/SourceGraph/Mutators/AssetReferenceRetainer.swift +++ b/Sources/SourceGraph/Mutators/AssetReferenceRetainer.swift @@ -1,3 +1,4 @@ +import Configuration import Foundation import Shared diff --git a/Sources/SourceGraph/Mutators/AssignOnlyPropertyReferenceEliminator.swift b/Sources/SourceGraph/Mutators/AssignOnlyPropertyReferenceEliminator.swift index e14fc2be3..37a352dd6 100644 --- a/Sources/SourceGraph/Mutators/AssignOnlyPropertyReferenceEliminator.swift +++ b/Sources/SourceGraph/Mutators/AssignOnlyPropertyReferenceEliminator.swift @@ -1,3 +1,4 @@ +import Configuration import Foundation import Shared @@ -11,7 +12,9 @@ final class AssignOnlyPropertyReferenceEliminator: SourceGraphMutator { required init(graph: SourceGraph, configuration: Configuration, swiftVersion _: SwiftVersion) { self.graph = graph self.configuration = configuration - retainAssignOnlyPropertyTypes = defaultRetainedTypes + configuration.retainAssignOnlyPropertyTypes + retainAssignOnlyPropertyTypes = defaultRetainedTypes + configuration.retainAssignOnlyPropertyTypes.map { + PropertyTypeSanitizer.sanitize($0) + } } func mutate() throws { diff --git a/Sources/SourceGraph/Mutators/CapitalSelfFunctionCallRetainer.swift b/Sources/SourceGraph/Mutators/CapitalSelfFunctionCallRetainer.swift index 24c62f482..638b9faa9 100644 --- a/Sources/SourceGraph/Mutators/CapitalSelfFunctionCallRetainer.swift +++ b/Sources/SourceGraph/Mutators/CapitalSelfFunctionCallRetainer.swift @@ -1,3 +1,4 @@ +import Configuration import Foundation import Shared diff --git a/Sources/SourceGraph/Mutators/CodablePropertyRetainer.swift b/Sources/SourceGraph/Mutators/CodablePropertyRetainer.swift index 485cf7ae5..354341355 100644 --- a/Sources/SourceGraph/Mutators/CodablePropertyRetainer.swift +++ b/Sources/SourceGraph/Mutators/CodablePropertyRetainer.swift @@ -1,3 +1,4 @@ +import Configuration import Foundation import Shared diff --git a/Sources/SourceGraph/Mutators/CodingKeyEnumReferenceBuilder.swift b/Sources/SourceGraph/Mutators/CodingKeyEnumReferenceBuilder.swift index 4b57d97ec..ae982b085 100644 --- a/Sources/SourceGraph/Mutators/CodingKeyEnumReferenceBuilder.swift +++ b/Sources/SourceGraph/Mutators/CodingKeyEnumReferenceBuilder.swift @@ -1,3 +1,4 @@ +import Configuration import Foundation import Shared diff --git a/Sources/SourceGraph/Mutators/ComplexPropertyAccessorReferenceBuilder.swift b/Sources/SourceGraph/Mutators/ComplexPropertyAccessorReferenceBuilder.swift index c616c4d4f..c2e6b05eb 100644 --- a/Sources/SourceGraph/Mutators/ComplexPropertyAccessorReferenceBuilder.swift +++ b/Sources/SourceGraph/Mutators/ComplexPropertyAccessorReferenceBuilder.swift @@ -1,3 +1,4 @@ +import Configuration import Foundation import Shared diff --git a/Sources/SourceGraph/Mutators/DefaultConstructorReferenceBuilder.swift b/Sources/SourceGraph/Mutators/DefaultConstructorReferenceBuilder.swift index 49f69ab4a..27f165404 100644 --- a/Sources/SourceGraph/Mutators/DefaultConstructorReferenceBuilder.swift +++ b/Sources/SourceGraph/Mutators/DefaultConstructorReferenceBuilder.swift @@ -1,3 +1,4 @@ +import Configuration import Foundation import Shared diff --git a/Sources/SourceGraph/Mutators/DynamicMemberLookupReferenceBuilder.swift b/Sources/SourceGraph/Mutators/DynamicMemberLookupReferenceBuilder.swift index a812ef4fc..d20dd3c35 100644 --- a/Sources/SourceGraph/Mutators/DynamicMemberLookupReferenceBuilder.swift +++ b/Sources/SourceGraph/Mutators/DynamicMemberLookupReferenceBuilder.swift @@ -1,3 +1,4 @@ +import Configuration import Foundation import Shared diff --git a/Sources/SourceGraph/Mutators/EntryPointAttributeRetainer.swift b/Sources/SourceGraph/Mutators/EntryPointAttributeRetainer.swift index 47ea5f173..cace1285c 100644 --- a/Sources/SourceGraph/Mutators/EntryPointAttributeRetainer.swift +++ b/Sources/SourceGraph/Mutators/EntryPointAttributeRetainer.swift @@ -1,3 +1,4 @@ +import Configuration import Foundation import Shared diff --git a/Sources/SourceGraph/Mutators/EnumCaseReferenceBuilder.swift b/Sources/SourceGraph/Mutators/EnumCaseReferenceBuilder.swift index 9bfff0e71..79414df2a 100644 --- a/Sources/SourceGraph/Mutators/EnumCaseReferenceBuilder.swift +++ b/Sources/SourceGraph/Mutators/EnumCaseReferenceBuilder.swift @@ -1,3 +1,4 @@ +import Configuration import Foundation import Shared diff --git a/Sources/SourceGraph/Mutators/ExtensionReferenceBuilder.swift b/Sources/SourceGraph/Mutators/ExtensionReferenceBuilder.swift index ebd9a61bc..ee7d4d1b9 100644 --- a/Sources/SourceGraph/Mutators/ExtensionReferenceBuilder.swift +++ b/Sources/SourceGraph/Mutators/ExtensionReferenceBuilder.swift @@ -1,3 +1,4 @@ +import Configuration import Foundation import Shared diff --git a/Sources/SourceGraph/Mutators/ExternalTypeProtocolConformanceReferenceRemover.swift b/Sources/SourceGraph/Mutators/ExternalTypeProtocolConformanceReferenceRemover.swift index adb61b7d5..40e1a3691 100644 --- a/Sources/SourceGraph/Mutators/ExternalTypeProtocolConformanceReferenceRemover.swift +++ b/Sources/SourceGraph/Mutators/ExternalTypeProtocolConformanceReferenceRemover.swift @@ -1,3 +1,4 @@ +import Configuration import Foundation import Shared diff --git a/Sources/SourceGraph/Mutators/GenericClassAndStructConstructorReferenceBuilder.swift b/Sources/SourceGraph/Mutators/GenericClassAndStructConstructorReferenceBuilder.swift index 4bac17c0e..0f053bbaf 100644 --- a/Sources/SourceGraph/Mutators/GenericClassAndStructConstructorReferenceBuilder.swift +++ b/Sources/SourceGraph/Mutators/GenericClassAndStructConstructorReferenceBuilder.swift @@ -1,3 +1,4 @@ +import Configuration import Foundation import Shared diff --git a/Sources/SourceGraph/Mutators/ObjCAccessibleRetainer.swift b/Sources/SourceGraph/Mutators/ObjCAccessibleRetainer.swift index 6ee74e5fd..9fe023c7a 100644 --- a/Sources/SourceGraph/Mutators/ObjCAccessibleRetainer.swift +++ b/Sources/SourceGraph/Mutators/ObjCAccessibleRetainer.swift @@ -1,3 +1,4 @@ +import Configuration import Foundation import Shared diff --git a/Sources/SourceGraph/Mutators/PropertyWrapperRetainer.swift b/Sources/SourceGraph/Mutators/PropertyWrapperRetainer.swift index 69e07e153..c6fbf7a30 100644 --- a/Sources/SourceGraph/Mutators/PropertyWrapperRetainer.swift +++ b/Sources/SourceGraph/Mutators/PropertyWrapperRetainer.swift @@ -1,3 +1,4 @@ +import Configuration import Foundation import Shared diff --git a/Sources/SourceGraph/Mutators/ProtocolConformanceReferenceBuilder.swift b/Sources/SourceGraph/Mutators/ProtocolConformanceReferenceBuilder.swift index dd0623335..7e3b68222 100644 --- a/Sources/SourceGraph/Mutators/ProtocolConformanceReferenceBuilder.swift +++ b/Sources/SourceGraph/Mutators/ProtocolConformanceReferenceBuilder.swift @@ -1,3 +1,4 @@ +import Configuration import Foundation import Shared diff --git a/Sources/SourceGraph/Mutators/ProtocolExtensionReferenceBuilder.swift b/Sources/SourceGraph/Mutators/ProtocolExtensionReferenceBuilder.swift index f93da5d76..8b479a5b4 100644 --- a/Sources/SourceGraph/Mutators/ProtocolExtensionReferenceBuilder.swift +++ b/Sources/SourceGraph/Mutators/ProtocolExtensionReferenceBuilder.swift @@ -1,3 +1,4 @@ +import Configuration import Foundation import Shared diff --git a/Sources/SourceGraph/Mutators/PubliclyAccessibleRetainer.swift b/Sources/SourceGraph/Mutators/PubliclyAccessibleRetainer.swift index dfb97d2f2..55329ebcd 100644 --- a/Sources/SourceGraph/Mutators/PubliclyAccessibleRetainer.swift +++ b/Sources/SourceGraph/Mutators/PubliclyAccessibleRetainer.swift @@ -1,3 +1,4 @@ +import Configuration import Foundation import Shared diff --git a/Sources/SourceGraph/Mutators/RedundantExplicitPublicAccessibilityMarker.swift b/Sources/SourceGraph/Mutators/RedundantExplicitPublicAccessibilityMarker.swift index 9e7ef3914..c4173d676 100644 --- a/Sources/SourceGraph/Mutators/RedundantExplicitPublicAccessibilityMarker.swift +++ b/Sources/SourceGraph/Mutators/RedundantExplicitPublicAccessibilityMarker.swift @@ -1,3 +1,4 @@ +import Configuration import Shared final class RedundantExplicitPublicAccessibilityMarker: SourceGraphMutator { diff --git a/Sources/SourceGraph/Mutators/RedundantProtocolMarker.swift b/Sources/SourceGraph/Mutators/RedundantProtocolMarker.swift index 49ad3f128..f36a8667d 100644 --- a/Sources/SourceGraph/Mutators/RedundantProtocolMarker.swift +++ b/Sources/SourceGraph/Mutators/RedundantProtocolMarker.swift @@ -1,3 +1,4 @@ +import Configuration import Foundation import Shared diff --git a/Sources/SourceGraph/Mutators/ResultBuilderRetainer.swift b/Sources/SourceGraph/Mutators/ResultBuilderRetainer.swift index 04915b994..e5ef18c8e 100644 --- a/Sources/SourceGraph/Mutators/ResultBuilderRetainer.swift +++ b/Sources/SourceGraph/Mutators/ResultBuilderRetainer.swift @@ -1,3 +1,4 @@ +import Configuration import Foundation import Shared diff --git a/Sources/SourceGraph/Mutators/StringInterpolationAppendInterpolationRetainer.swift b/Sources/SourceGraph/Mutators/StringInterpolationAppendInterpolationRetainer.swift index 96e64714c..99be47a61 100644 --- a/Sources/SourceGraph/Mutators/StringInterpolationAppendInterpolationRetainer.swift +++ b/Sources/SourceGraph/Mutators/StringInterpolationAppendInterpolationRetainer.swift @@ -1,3 +1,4 @@ +import Configuration import Foundation import Shared diff --git a/Sources/SourceGraph/Mutators/StructImplicitInitializerReferenceBuilder.swift b/Sources/SourceGraph/Mutators/StructImplicitInitializerReferenceBuilder.swift index fb793d19c..e55ba9512 100644 --- a/Sources/SourceGraph/Mutators/StructImplicitInitializerReferenceBuilder.swift +++ b/Sources/SourceGraph/Mutators/StructImplicitInitializerReferenceBuilder.swift @@ -1,3 +1,4 @@ +import Configuration import Foundation import Shared diff --git a/Sources/SourceGraph/Mutators/SwiftUIRetainer.swift b/Sources/SourceGraph/Mutators/SwiftUIRetainer.swift index a76fec8c7..17e1134c2 100644 --- a/Sources/SourceGraph/Mutators/SwiftUIRetainer.swift +++ b/Sources/SourceGraph/Mutators/SwiftUIRetainer.swift @@ -1,3 +1,4 @@ +import Configuration import Foundation import Shared diff --git a/Sources/SourceGraph/Mutators/UnusedImportMarker.swift b/Sources/SourceGraph/Mutators/UnusedImportMarker.swift index 4359800f4..0a48fb14f 100644 --- a/Sources/SourceGraph/Mutators/UnusedImportMarker.swift +++ b/Sources/SourceGraph/Mutators/UnusedImportMarker.swift @@ -1,3 +1,4 @@ +import Configuration import Foundation import Shared diff --git a/Sources/SourceGraph/Mutators/UnusedParameterRetainer.swift b/Sources/SourceGraph/Mutators/UnusedParameterRetainer.swift index 68d22c559..383186c65 100644 --- a/Sources/SourceGraph/Mutators/UnusedParameterRetainer.swift +++ b/Sources/SourceGraph/Mutators/UnusedParameterRetainer.swift @@ -1,3 +1,4 @@ +import Configuration import Foundation import Shared diff --git a/Sources/SourceGraph/Mutators/UsedDeclarationMarker.swift b/Sources/SourceGraph/Mutators/UsedDeclarationMarker.swift index 852ef82c0..a54b79564 100644 --- a/Sources/SourceGraph/Mutators/UsedDeclarationMarker.swift +++ b/Sources/SourceGraph/Mutators/UsedDeclarationMarker.swift @@ -1,3 +1,4 @@ +import Configuration import Foundation import Shared diff --git a/Sources/SourceGraph/Mutators/XCTestRetainer.swift b/Sources/SourceGraph/Mutators/XCTestRetainer.swift index 057bee7cf..53f595cf6 100644 --- a/Sources/SourceGraph/Mutators/XCTestRetainer.swift +++ b/Sources/SourceGraph/Mutators/XCTestRetainer.swift @@ -1,3 +1,4 @@ +import Configuration import Foundation import Shared diff --git a/Sources/SourceGraph/SourceGraph.swift b/Sources/SourceGraph/SourceGraph.swift index 010b5f805..65ecd535d 100644 --- a/Sources/SourceGraph/SourceGraph.swift +++ b/Sources/SourceGraph/SourceGraph.swift @@ -1,3 +1,4 @@ +import Configuration import Foundation import Shared diff --git a/Sources/SourceGraph/SourceGraphMutator.swift b/Sources/SourceGraph/SourceGraphMutator.swift index 8cde225a3..194386417 100644 --- a/Sources/SourceGraph/SourceGraphMutator.swift +++ b/Sources/SourceGraph/SourceGraphMutator.swift @@ -1,3 +1,4 @@ +import Configuration import Foundation import Shared diff --git a/Sources/SourceGraph/SourceGraphMutatorRunner.swift b/Sources/SourceGraph/SourceGraphMutatorRunner.swift index 7b4508721..71b9025ad 100644 --- a/Sources/SourceGraph/SourceGraphMutatorRunner.swift +++ b/Sources/SourceGraph/SourceGraphMutatorRunner.swift @@ -1,4 +1,6 @@ +import Configuration import Foundation +import Logger import Shared public final class SourceGraphMutatorRunner { diff --git a/Sources/XcodeSupport/XcodeProject.swift b/Sources/XcodeSupport/XcodeProject.swift index 80d593f0c..173cd68f9 100644 --- a/Sources/XcodeSupport/XcodeProject.swift +++ b/Sources/XcodeSupport/XcodeProject.swift @@ -1,4 +1,5 @@ import Foundation +import Logger import Shared import SystemPackage import XcodeProj diff --git a/Sources/XcodeSupport/XcodeProjectSetupGuide.swift b/Sources/XcodeSupport/XcodeProjectSetupGuide.swift index 53abef853..825493f54 100644 --- a/Sources/XcodeSupport/XcodeProjectSetupGuide.swift +++ b/Sources/XcodeSupport/XcodeProjectSetupGuide.swift @@ -1,4 +1,6 @@ +import Configuration import Foundation +import Logger import Shared import SystemPackage diff --git a/Sources/XcodeSupport/XcodeWorkspace.swift b/Sources/XcodeSupport/XcodeWorkspace.swift index 65a49d944..b6faea57c 100644 --- a/Sources/XcodeSupport/XcodeWorkspace.swift +++ b/Sources/XcodeSupport/XcodeWorkspace.swift @@ -1,4 +1,6 @@ +import Configuration import Foundation +import Logger import Shared import SystemPackage import XcodeProj diff --git a/Sources/XcodeSupport/Xcodebuild.swift b/Sources/XcodeSupport/Xcodebuild.swift index e15969b31..92ed1d310 100644 --- a/Sources/XcodeSupport/Xcodebuild.swift +++ b/Sources/XcodeSupport/Xcodebuild.swift @@ -1,4 +1,5 @@ import Foundation +import Logger import Shared import SystemPackage diff --git a/Tests/PeripheryTests/Extensions/FilePathGlobTest.swift b/Tests/PeripheryTests/Extensions/FilePathGlobTest.swift index a0f2e546b..16b3699ba 100644 --- a/Tests/PeripheryTests/Extensions/FilePathGlobTest.swift +++ b/Tests/PeripheryTests/Extensions/FilePathGlobTest.swift @@ -1,4 +1,3 @@ -import Shared import SystemPackage import XCTest diff --git a/Tests/PeripheryTests/Extensions/FilenameMatcherTests.swift b/Tests/PeripheryTests/Extensions/FilenameMatcherTests.swift index 2efc42d06..9441e2b69 100644 --- a/Tests/PeripheryTests/Extensions/FilenameMatcherTests.swift +++ b/Tests/PeripheryTests/Extensions/FilenameMatcherTests.swift @@ -1,6 +1,5 @@ import FilenameMatcher import Foundation -import Shared import XCTest final class FilenameMatcherTests: XCTestCase { diff --git a/Tests/PeripheryTests/RetentionTest.swift b/Tests/PeripheryTests/RetentionTest.swift index 4c326372d..0b5d6d687 100644 --- a/Tests/PeripheryTests/RetentionTest.swift +++ b/Tests/PeripheryTests/RetentionTest.swift @@ -1,4 +1,3 @@ -import Shared import SystemPackage @testable import TestShared import XCTest diff --git a/Tests/PeripheryTests/ShellTest.swift b/Tests/PeripheryTests/ShellTest.swift index 2adb009ac..ab2afd882 100644 --- a/Tests/PeripheryTests/ShellTest.swift +++ b/Tests/PeripheryTests/ShellTest.swift @@ -1,3 +1,4 @@ +import Logger @testable import Shared import XCTest @@ -9,8 +10,7 @@ final class ShellTest: XCTestCase { "PATH": path, "DEVELOPER_DIR": developerDir, ] - let configuration = Configuration() - let logger = Logger(configuration: configuration) + let logger = Logger(quiet: true) let shell = Shell(environment: environment, logger: logger) XCTAssertEqual(shell.pristineEnvironment["PATH"], path) XCTAssertEqual(shell.pristineEnvironment["DEVELOPER_DIR"], developerDir) diff --git a/Tests/Shared/SPMSourceGraphTestCase.swift b/Tests/Shared/SPMSourceGraphTestCase.swift index 4eec86920..f51069a33 100644 --- a/Tests/Shared/SPMSourceGraphTestCase.swift +++ b/Tests/Shared/SPMSourceGraphTestCase.swift @@ -1,6 +1,5 @@ import Foundation import ProjectDrivers -import Shared import SystemPackage class SPMSourceGraphTestCase: SourceGraphTestCase { diff --git a/Tests/Shared/SourceGraphTestCase.swift b/Tests/Shared/SourceGraphTestCase.swift index 899ddebf2..a3c1aa770 100644 --- a/Tests/Shared/SourceGraphTestCase.swift +++ b/Tests/Shared/SourceGraphTestCase.swift @@ -1,4 +1,6 @@ +import Configuration @testable import Indexer +import Logger @testable import PeripheryKit import Shared @testable import SourceGraph @@ -23,7 +25,7 @@ open class SourceGraphTestCase: XCTestCase { super.setUp() configuration = Configuration() configuration.quiet = true - logger = Logger(configuration: configuration) + logger = Logger(quiet: true) shell = Shell(logger: logger) graph = SourceGraph(configuration: configuration) } diff --git a/Tests/XcodeTests/ShellMock.swift b/Tests/XcodeTests/ShellMock.swift index 045825df2..0ae7918d6 100644 --- a/Tests/XcodeTests/ShellMock.swift +++ b/Tests/XcodeTests/ShellMock.swift @@ -1,12 +1,12 @@ import Foundation +import Logger import Shared class ShellMock: Shell { var output: String = "" convenience init() { - let configuration = Configuration() - let logger = Logger(configuration: configuration) + let logger = Logger(quiet: true) self.init(environment: ProcessInfo.processInfo.environment, logger: logger) } diff --git a/Tests/XcodeTests/XcodeSourceGraphTestCase.swift b/Tests/XcodeTests/XcodeSourceGraphTestCase.swift index 7442172c7..104087cb5 100644 --- a/Tests/XcodeTests/XcodeSourceGraphTestCase.swift +++ b/Tests/XcodeTests/XcodeSourceGraphTestCase.swift @@ -1,6 +1,5 @@ import Foundation import ProjectDrivers -import Shared import SystemPackage @testable import TestShared diff --git a/Tests/XcodeTests/XcodeTargetTest.swift b/Tests/XcodeTests/XcodeTargetTest.swift index d28a5cd23..b8f2fb779 100644 --- a/Tests/XcodeTests/XcodeTargetTest.swift +++ b/Tests/XcodeTests/XcodeTargetTest.swift @@ -1,4 +1,5 @@ import Foundation +import Logger import Shared @testable import TestShared @testable import XcodeSupport @@ -9,8 +10,7 @@ final class XcodeTargetTest: XCTestCase { override func setUp() { super.setUp() - let configuration = Configuration() - let logger = Logger(configuration: configuration) + let logger = Logger(quiet: true) let shell = Shell(logger: logger) let xcodebuild = Xcodebuild(shell: shell, logger: logger) project = try! XcodeProject( diff --git a/Tests/XcodeTests/XcodebuildBuildProjectTest.swift b/Tests/XcodeTests/XcodebuildBuildProjectTest.swift index 5166e6b1c..8e8f8144c 100644 --- a/Tests/XcodeTests/XcodebuildBuildProjectTest.swift +++ b/Tests/XcodeTests/XcodebuildBuildProjectTest.swift @@ -1,4 +1,5 @@ import Foundation +import Logger import Shared @testable import XcodeSupport import XCTest @@ -10,8 +11,7 @@ final class XcodebuildBuildProjectTest: XCTestCase { override func setUp() { super.setUp() - let configuration = Configuration() - let logger = Logger(configuration: configuration) + let logger = Logger(quiet: true) let shell = Shell(logger: logger) xcodebuild = Xcodebuild(shell: shell, logger: logger) project = try! XcodeProject(path: UIKitProjectPath, xcodebuild: xcodebuild, shell: shell, logger: logger) diff --git a/Tests/XcodeTests/XcodebuildSchemesTest.swift b/Tests/XcodeTests/XcodebuildSchemesTest.swift index 3a7821b8b..5fb3bebfb 100644 --- a/Tests/XcodeTests/XcodebuildSchemesTest.swift +++ b/Tests/XcodeTests/XcodebuildSchemesTest.swift @@ -1,5 +1,5 @@ import Foundation -import Shared +import Logger @testable import XcodeSupport import XCTest @@ -12,8 +12,7 @@ final class XcodebuildSchemesTest: XCTestCase { super.setUp() shell = ShellMock() - let configuration = Configuration() - let logger = Logger(configuration: configuration) + let logger = Logger(quiet: true) xcodebuild = Xcodebuild(shell: shell, logger: logger) project = try! XcodeProject(path: UIKitProjectPath, xcodebuild: xcodebuild, shell: shell, logger: logger) }