Improve StyleViolation reason formatting validation (#4946)

So it checks violations for all rules in the registry, not just the
built-in rules.
This commit is contained in:
JP Simard 2023-04-26 14:54:44 -04:00 committed by GitHub
parent 72c2a5488d
commit a7e3909c6a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 1 deletions

View File

@ -42,7 +42,7 @@ public struct StyleViolation: CustomStringConvertible, Equatable, Codable {
self.reason = reason ?? ruleDescription.description
#if DEBUG
if self.reason.trimmingTrailingCharacters(in: .whitespaces).last == ".",
builtInRules.contains(where: { rule in rule.description.identifier == self.ruleIdentifier }) {
RuleRegistry.shared.rule(forID: self.ruleIdentifier) != nil {
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.