diff --git a/updateSwiftLintProfile.groovy b/updateSwiftLintProfile.groovy index e8134bdf..25c9dbf9 100644 --- a/updateSwiftLintProfile.groovy +++ b/updateSwiftLintProfile.groovy @@ -18,8 +18,11 @@ // Update profile-swiftlint.xml from local rules.txt // Severity is determined from ... +@Grab(group='org.yaml', module='snakeyaml', version='1.5') + import groovy.xml.MarkupBuilder import groovy.json.JsonBuilder +import org.yaml.snakeyaml.* def magicSerevityAttribution(rule) { @@ -74,6 +77,20 @@ def readSwiftLintRules() { } + // Extract custom rule identifiers and get details + Yaml parser = new Yaml() + FileReader swiftlintDotfile = new FileReader('.swiftlint.yml') + HashMap swiftlintDotfileContent = parser.load(swiftlintDotfile) + swiftlintDotfileContent.custom_rules.each {ruleKey, ruleContent -> + + def rule = [:] + rule.key = ruleKey + rule.name = ruleContent.name + rule.description = ruleContent.message + + result.add rule + } + result }