Files
SwiftLint/Source/SwiftLintCore/Rules/SuperfluousDisableCommandRule.swift
T
Danny MöschandGitHub 3f039f26d5 Connect configs with their referencing rules to have some context in error logging (#5017)
With the binding of configurations to their associated rule types
"unknown configuration" errors can be made more specific mentioning
also the rule's identifier in the printed message.
2023-05-19 20:58:24 +02:00

33 lines
1.1 KiB
Swift

@_spi(TestHelper)
public struct SuperfluousDisableCommandRule: ConfigurationProviderRule, SourceKitFreeRule {
public var configuration = SeverityConfiguration<Self>(.warning)
public init() {}
public static let description = RuleDescription(
identifier: "superfluous_disable_command",
name: "Superfluous Disable Command",
description: """
SwiftLint 'disable' commands are superfluous when the disabled rule would not have triggered a violation \
in the disabled region. Use " - " if you wish to document a command.
""",
kind: .lint
)
public func validate(file: SwiftLintFile) -> [StyleViolation] {
// This rule is implemented in Linter.swift
return []
}
func reason(for rule: Rule.Type) -> String {
"""
SwiftLint rule '\(rule.description.identifier)' did not trigger a violation in the disabled region; \
remove the disable command
"""
}
func reason(forNonExistentRule rule: String) -> String {
return "'\(rule)' is not a valid SwiftLint rule; remove it from the disable command"
}
}