-
Notifications
You must be signed in to change notification settings - Fork 2.2k
/
Copy pathLint.swift
64 lines (61 loc) · 2.51 KB
/
Lint.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import ArgumentParser
import SwiftLintFramework
extension SwiftLint {
struct Lint: AsyncParsableCommand {
static let configuration = CommandConfiguration(abstract: "Print lint warnings and errors")
@OptionGroup
var common: LintOrAnalyzeArguments
@Option(help: pathOptionDescription(for: .lint))
var path: String?
@Flag(help: "Lint standard input.")
var useSTDIN = false
@Flag(help: quietOptionDescription(for: .lint))
var quiet = false
@Option(help: "The directory of the cache used when linting.")
var cachePath: String?
@Flag(help: "Ignore cache when linting.")
var noCache = false
@Flag(help: "Run all rules, even opt-in and disabled ones, ignoring `only_rules`.")
var enableAllRules = false
@Argument(help: pathsArgumentDescription(for: .lint))
var paths = [String]()
func run() async throws {
let allPaths: [String]
if let path = path {
queuedPrintError("""
warning: The --path option is deprecated. Pass the path(s) to lint last to the swiftlint command.
""")
allPaths = [path] + paths
} else if !paths.isEmpty {
allPaths = paths
} else {
allPaths = [""] // Lint files in current working directory if no paths were specified.
}
let options = LintOrAnalyzeOptions(
mode: .lint,
paths: allPaths,
useSTDIN: useSTDIN,
configurationFiles: common.config,
strict: common.leniency == .strict,
lenient: common.leniency == .lenient,
forceExclude: common.forceExclude,
useExcludingByPrefix: common.useAlternativeExcluding,
useScriptInputFiles: common.useScriptInputFiles,
benchmark: common.benchmark,
reporter: common.reporter,
quiet: quiet,
output: common.output,
progress: common.progress,
cachePath: cachePath,
ignoreCache: noCache,
enableAllRules: enableAllRules,
autocorrect: common.fix,
format: common.format,
compilerLogPath: nil,
compileCommands: nil,
inProcessSourcekit: common.inProcessSourcekit
)
try await LintOrAnalyzeCommand.run(options)
}
}
}