     public func validate(file: File, kind: SwiftExpressionKind,
                          dictionary: [String: SourceKitRepresentable]) -> [StyleViolation] {
         if let (index, reason) = violationIndexAndReason(in: file, kind: kind, dictionary: dictionary) {
-            return violations(file: file, byteOffset: index, reason: reason)
+            return violations(file: file, byteOffset: index, reason: reason.rawValue)
         } else {
             return []
         }
     }
 
     private func violationIndexAndReason(in file: File, kind: SwiftExpressionKind,
-                                dictionary: [String: SourceKitRepresentable]) -> (Int, String)? {
+                                         dictionary: [String: SourceKitRepresentable]) -> CommaRuleViolation? {
         let allowedKinds: [SwiftExpressionKind] = [.array, .dictionary]
 
         guard let bodyOffset = dictionary.bodyOffset,

                return nil
            }

            return (lastPosition, missingTrailingCommaReason)
        }

        // trailing comma is present, which is a violation if mandatoryComma is false

    }

    public func correct(file: File) -> [Correction] {
        let violatingIndexes = file.structure.dictionary.substructure.flatMap { sub -> CommaRuleViolation? in
            guard let kind = SwiftExpressionKind(rawValue: sub.kind ?? "") else { return nil }
            return violationIndexAndReason(in: file, kind: kind, dictionary: sub)
        }

        let adjustedIndexes = violatingIndexes.reduce([CommaRuleViolation]()) { adjustedIndexes, element in
            let correction: Int
            switch element.reason {
            case .missingTrailingCommaReason:
                correction = adjustedIndexes.count
            case .extraTrailingCommaReason:
                correction = -adjustedIndexes.count
            }

            return adjustedIndexes + [(element.index + correction, element.reason)]
        }

        var correctedContents = file.contents

        adjustedIndexes.forEach {
            let stringIndex = correctedContents.index(correctedContents.startIndex, offsetBy: $0.index)
            switch $0.reason {
            case .missingTrailingCommaReason:
                correctedContents.insert(",", at: stringIndex)
            case .extraTrailingCommaReason:
                correctedContents.remove(at: stringIndex)
            }
        }

        file.write(correctedContents)

        return adjustedIndexes.map {
            Correction(ruleDescription: type(of: self).description,
                       location: Location(file: file, characterOffset: $0.index))
        }
    }
}
