Sha256: 182bf7cf0e61f2ba120e7aa9690d800724ddd47132e71d511901f4f341cba1e7
Contents?: true
Size: 1.44 KB
Versions: 1
Compression:
Stored size: 1.44 KB
Contents
require 'json' require 'rexml/document' module BrakemanTranslateCheckstyleFormat module Translate def parse(json) JSON .parse(json) end def trans(json) doc = REXML::Document.new doc << REXML::XMLDecl.new('1.0', 'UTF-8') checkstyle = doc.add_element('checkstyle') warnings = json['warnings'] if warnings.empty? BrakemanTranslateCheckstyleFormat::Translate.set_dummy(json, checkstyle) return doc end warnings.each do |warning| file = checkstyle.add_element('file', 'name' => BrakemanTranslateCheckstyleFormat::Translate.convert_to_absolute(warning, json) ) file.add_element('error', 'line' => warning['line'], 'severity' => 'error', 'message' => BrakemanTranslateCheckstyleFormat::Translate.create_message(warning) ) end doc end def self.convert_to_absolute(warning, json) "#{json['scan_info']['app_path']}/#{warning['file']}" end def self.set_dummy(json, checkstyle) checkstyle.add_element('file', 'name' => '' ) checkstyle end def self.create_message(warning) "[#{warning['confidence']}][#{warning['warning_type']}] #{warning['message']}\n#{warning['link']}" end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
brakeman_translate_checkstyle_format-0.0.1 | lib/brakeman_translate_checkstyle_format/translate.rb |