Check every used internal violation reason for a pending period

This commit is contained in:
Danny Mösch 2023-01-08 16:37:32 +01:00
parent e64e82d80d
commit cc44c989b7
4 changed files with 25 additions and 7 deletions

View File

@ -1,4 +1,8 @@
/// The rule list containing all available rules built into SwiftLint.
public let primaryRuleList = RuleList(rules: [
let builtInRules: [Rule.Type] = [
{% for rule in types.structs where rule.name|hasSuffix:"Rule" or rule.name|hasSuffix:"Rules" %} {{ rule.name }}.self{% if not forloop.last %},{% endif %}
{% endfor %}] + extraRules())
{% endfor %}]
/// The rule list containing all available rules built into SwiftLint as well as native custom rules.
public let primaryRuleList = RuleList(rules: builtInRules + extraRules())

View File

@ -1,7 +1,8 @@
// Generated using Sourcery 1.9.0 https://github.com/krzysztofzablocki/Sourcery
// Generated using Sourcery 1.9.2 https://github.com/krzysztofzablocki/Sourcery
// DO NOT EDIT
/// The rule list containing all available rules built into SwiftLint.
public let primaryRuleList = RuleList(rules: [
let builtInRules: [Rule.Type] = [
AccessibilityLabelForImageRule.self,
AccessibilityTraitForButtonRule.self,
AnonymousArgumentInMultilineClosureRule.self,
@ -223,4 +224,7 @@ public let primaryRuleList = RuleList(rules: [
XCTFailMessageRule.self,
XCTSpecificMatcherRule.self,
YodaConditionRule.self
] + extraRules())
]
/// The rule list containing all available rules built into SwiftLint as well as native custom rules.
public let primaryRuleList = RuleList(rules: builtInRules + extraRules())

View File

@ -28,7 +28,8 @@ public struct StyleViolation: CustomStringConvertible, Equatable, Codable {
/// - parameter ruleDescription: The description of the rule that generated this violation.
/// - parameter severity: The severity of this violation.
/// - parameter location: The location of this violation.
/// - parameter reason: The justification for this violation.
/// - parameter reason: The justification for this violation. If not specified the rule's description will
/// be used.
public init(ruleDescription: RuleDescription,
severity: ViolationSeverity = .warning,
location: Location,
@ -39,6 +40,15 @@ public struct StyleViolation: CustomStringConvertible, Equatable, Codable {
self.severity = severity
self.location = location
self.reason = reason ?? ruleDescription.description
#if DEBUG
if self.reason.trimmingTrailingCharacters(in: .whitespaces).last == ".",
builtInRules.contains(where: { rule in rule.description.identifier == self.ruleIdentifier }) {
queuedFatalError("""
Reasons shall not end with a period. Got "\(self.reason)". Either rewrite the rule's description \
or set a custom reason in the StyleViolation's constructor.
""")
}
#endif
}
/// Returns the same violation, but with the `severity` that is passed in

View File

@ -1,4 +1,4 @@
// Generated using Sourcery 1.9.0 https://github.com/krzysztofzablocki/Sourcery
// Generated using Sourcery 1.9.2 https://github.com/krzysztofzablocki/Sourcery
// DO NOT EDIT
@_spi(TestHelper)
@testable import SwiftLintFramework