Skip to content

Commit

Permalink
Add new --quiet-deprecation-warnings flag to silence deprecation wa…
Browse files Browse the repository at this point in the history
…rnings
  • Loading branch information
SimplyDanny committed May 16, 2023
1 parent fe312a0 commit 580e858
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 0 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@
[SimplyDanny](https://github.com/SimplyDanny)
[#4990](https://github.com/realm/SwiftLint/issues/4990)

* Add new `--quiet-deprecation-warnings` flag that silences deprecation
warnings that would otherwise be printed to the console.
[SimplyDanny](https://github.com/SimplyDanny)
[#4989](https://github.com/realm/SwiftLint/issues/4989)

#### Bug Fixes

* Do not trigger `prefer_self_in_static_references` rule on `typealias`
Expand Down
6 changes: 6 additions & 0 deletions Source/SwiftLintCore/Models/Issue.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ public enum Issue: LocalizedError, Equatable {
/// An error that occurred when parsing YAML.
case yamlParsing(String)

/// Flag to enable warnings for deprecations being printed to the console. Printing is enabled by default.
public static var printDeprecationWarnings = true

/// Wraps any `Error` into a `SwiftLintError.genericWarning` if it is not already a `SwiftLintError`.
///
/// - parameter error: Any `Error`.
Expand Down Expand Up @@ -75,6 +78,9 @@ public enum Issue: LocalizedError, Equatable {

/// Print the issue to the console.
public func print() {
if case .ruleDeprecated = self, !Self.printDeprecationWarnings {
return
}
queuedPrintError(errorDescription)
}

Expand Down
3 changes: 3 additions & 0 deletions Source/swiftlint/Commands/Lint.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ extension SwiftLint {
var paths = [String]()

func run() async throws {
if common.quietDeprecationWarnings {
Issue.printDeprecationWarnings = false
}
let allPaths: [String]
if let path {
// TODO: [06/14/2024] Remove deprecation warning after ~2 years.
Expand Down
2 changes: 2 additions & 0 deletions Source/swiftlint/Helpers/LintOrAnalyzeArguments.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ struct LintOrAnalyzeArguments: ParsableArguments {
var output: String?
@Flag(help: "Show a live-updating progress bar instead of each file being processed.")
var progress = false
@Flag(help: "Do not print deprecation warnings.")
var quietDeprecationWarnings = false
}

// MARK: - Common Argument Help
Expand Down

0 comments on commit 580e858

Please sign in to comment.