mirror of
https://github.com/realm/SwiftLint.git
synced 2026-05-07 20:12:49 +00:00
57 lines
2.3 KiB
Swift
57 lines
2.3 KiB
Swift
import ArgumentParser
|
|
import SwiftLintFramework
|
|
|
|
extension SwiftLint {
|
|
struct Analyze: AsyncParsableCommand {
|
|
static let configuration = CommandConfiguration(abstract: "Run analysis rules")
|
|
|
|
@OptionGroup
|
|
var common: LintOrAnalyzeArguments
|
|
@Flag(help: quietOptionDescription(for: .analyze))
|
|
var quiet = false
|
|
@Option(help: "The path of the full xcodebuild log to use when running AnalyzerRules.")
|
|
var compilerLogPath: String?
|
|
@Option(help: "The path of a compilation database to use when running AnalyzerRules.")
|
|
var compileCommands: String?
|
|
@Argument(help: pathsArgumentDescription(for: .analyze))
|
|
var paths = [String]()
|
|
|
|
func run() async throws {
|
|
// Analyze files in current working directory if no paths were specified.
|
|
let allPaths = paths.isNotEmpty ? paths : [""]
|
|
let options = LintOrAnalyzeOptions(
|
|
mode: .analyze,
|
|
paths: allPaths,
|
|
useSTDIN: false,
|
|
configurationFiles: common.config,
|
|
strict: common.leniency == .strict,
|
|
lenient: common.leniency == .lenient,
|
|
forceExclude: common.forceExclude,
|
|
useExcludingByPrefix: common.useAlternativeExcluding,
|
|
useScriptInputFiles: common.useScriptInputFiles,
|
|
useScriptInputFileLists: common.useScriptInputFileLists,
|
|
benchmark: common.benchmark,
|
|
reporter: common.reporter,
|
|
baseline: common.baseline,
|
|
writeBaseline: common.writeBaseline,
|
|
workingDirectory: common.workingDirectory,
|
|
quiet: quiet,
|
|
output: common.output,
|
|
progress: common.progress,
|
|
cachePath: nil,
|
|
ignoreCache: true,
|
|
enableAllRules: false,
|
|
onlyRule: common.onlyRule,
|
|
autocorrect: common.fix,
|
|
format: common.format,
|
|
disableSourceKit: false,
|
|
compilerLogPath: compilerLogPath,
|
|
compileCommands: compileCommands,
|
|
checkForUpdates: common.checkForUpdates
|
|
)
|
|
|
|
try await LintOrAnalyzeCommand.run(options)
|
|
}
|
|
}
|
|
}
|