Skip to content

Commit

Permalink
Move --only-rule option to common arguments (#5981)
Browse files Browse the repository at this point in the history
  • Loading branch information
SimplyDanny authored Feb 12, 2025
1 parent b1198b7 commit 364442a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 18 deletions.
10 changes: 1 addition & 9 deletions Source/swiftlint/Commands/Analyze.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,6 @@ extension SwiftLint {
var compilerLogPath: String?
@Option(help: "The path of a compilation database to use when running AnalyzerRules.")
var compileCommands: String?
@Option(
parsing: .singleValue,
help: """
Run only the specified rule, ignoring `only_rules`, `opt_in_rules` and `disabled_rules`.
Can be specified repeatedly to run multiple rules.
"""
)
var onlyRule: [String] = []
@Argument(help: pathsArgumentDescription(for: .analyze))
var paths = [String]()

Expand Down Expand Up @@ -49,7 +41,7 @@ extension SwiftLint {
cachePath: nil,
ignoreCache: true,
enableAllRules: false,
onlyRule: onlyRule,
onlyRule: common.onlyRule,
autocorrect: common.fix,
format: common.format,
compilerLogPath: compilerLogPath,
Expand Down
10 changes: 1 addition & 9 deletions Source/swiftlint/Commands/Lint.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,6 @@ extension SwiftLint {
var noCache = false
@Flag(help: "Run all rules, even opt-in and disabled ones, ignoring `only_rules`.")
var enableAllRules = false
@Option(
parsing: .singleValue,
help: """
Run only the specified rule, ignoring `only_rules`, `opt_in_rules` and `disabled_rules`.
Can be specified repeatedly to run multiple rules.
"""
)
var onlyRule: [String] = []
@Argument(help: pathsArgumentDescription(for: .lint))
var paths = [String]()

Expand Down Expand Up @@ -61,7 +53,7 @@ extension SwiftLint {
cachePath: cachePath,
ignoreCache: noCache,
enableAllRules: enableAllRules,
onlyRule: onlyRule,
onlyRule: common.onlyRule,
autocorrect: common.fix,
format: common.format,
compilerLogPath: nil,
Expand Down
8 changes: 8 additions & 0 deletions Source/swiftlint/Common/LintOrAnalyzeArguments.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,14 @@ struct LintOrAnalyzeArguments: ParsableArguments {
var progress = false
@Flag(help: "Check whether a later version of SwiftLint is available after processing all files.")
var checkForUpdates = false
@Option(
parsing: .singleValue,
help: """
Run only the specified rule, ignoring `only_rules`, `opt_in_rules` and `disabled_rules`.
Can be specified repeatedly to run multiple rules.
"""
)
var onlyRule: [String] = []
}

// MARK: - Common Argument Help
Expand Down

0 comments on commit 364442a

Please sign in to comment.