Fail in debug builds if a rule produces corrections while not being correctable (#5684)

This commit is contained in:
Danny Mösch
2024-07-20 19:11:55 +02:00
committed by GitHub
parent cb0f5ab007
commit b63807de6d
@@ -46,8 +46,13 @@ public extension SwiftSyntaxRule {
return []
}
return makeVisitor(file: file)
let violations = makeVisitor(file: file)
.walk(tree: syntaxTree, handler: \.violations)
assert(
violations.allSatisfy { $0.correction == nil || self is any SwiftSyntaxCorrectableRule },
"\(Self.self) produced corrections without being correctable."
)
return violations
.sorted()
.map { makeViolation(file: file, violation: $0) }
}