Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new --silence-deprecation-warnings flag #5014

Merged
merged 1 commit into from
Jun 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@
(e.g. `@testable`, `@_exported`, ...).
[hiltonc](https://github.com/hiltonc)

* Add new `--quiet-deprecation-warnings` flag that silences deprecation
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh bummer! Thank you for the prompt correction.

warnings that would otherwise be printed to the console.
[SimplyDanny](https://github.com/SimplyDanny)
[#4989](https://github.com/realm/SwiftLint/issues/4989)

* Do not trigger `redundant_self_in_closure` rule when another idenfier `x` in
scope shadows the field accessed by `self.x` to avoid semantical changes.
[SimplyDanny](https://github.com/SimplyDanny)
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
4 changes: 4 additions & 0 deletions Source/swiftlint/Commands/Lint.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ extension SwiftLint {
var useSTDIN = false
@Flag(help: quietOptionDescription(for: .lint))
var quiet = false
@Flag(help: "Don't print deprecation warnings.")
var silenceDeprecationWarnings = false
@Option(help: "The directory of the cache used when linting.")
var cachePath: String?
@Flag(help: "Ignore cache when linting.")
Expand All @@ -23,6 +25,8 @@ extension SwiftLint {
var paths = [String]()

func run() async throws {
Issue.printDeprecationWarnings = !silenceDeprecationWarnings

let allPaths: [String]
if let path {
// TODO: [06/14/2024] Remove deprecation warning after ~2 years.
Expand Down