Sha256: 86f5c9cf00c3a0230f301ac97ddf4b4f2ab90d55b444f5c3df86162f7a4937b4
Contents?: true
Size: 1.34 KB
Versions: 1
Compression:
Stored size: 1.34 KB
Contents
require 'json' require 'rexml/document' module SwiftlintTranslateCheckstyleFormat module Translate def parse(str) JSON.load(str) end def trans(json) doc = REXML::Document.new doc << REXML::XMLDecl.new('1.0', 'UTF-8') checkstyle = doc.add_element('checkstyle') if json.empty? SwiftlintTranslateCheckstyleFormat::Translate.add_dummy(checkstyle) return doc end json.each do |result| file = checkstyle.add_element('file', 'name' => SwiftlintTranslateCheckstyleFormat::Translate.create_path(result['file'], json) ) file.add_element('error', 'line' => result['line'], 'severity' => 'error', 'message' => SwiftlintTranslateCheckstyleFormat::Translate.create_message(result) ) end doc end def self.create_path(fila_path, json) fila_path.gsub(Dir.pwd, '') end def self.add_dummy(checkstyle) checkstyle.add_element('file', 'name' => '' ) checkstyle end def self.create_message(result) "[#{result['severity']}][#{result['rule_id']}] #{result['type']}\n#{result['reason']}" end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
swiftlint_translate_checkstyle_format-0.1.0 | lib/swiftlint_translate_checkstyle_format/translate.rb |