Module: BrakemanTranslateCheckstyleFormat::Translate
- Included in:
- CLI
- Defined in:
- lib/brakeman_translate_checkstyle_format/translate.rb
Class Method Summary collapse
- .convert_to_absolute(warning, json) ⇒ Object
- .create_message(warning) ⇒ Object
- .set_dummy(json, checkstyle) ⇒ Object
Instance Method Summary collapse
Class Method Details
.convert_to_absolute(warning, json) ⇒ Object
36 37 38 |
# File 'lib/brakeman_translate_checkstyle_format/translate.rb', line 36 def self.convert_to_absolute(warning, json) "#{json['scan_info']['app_path']}/#{warning['file']}" end |
.create_message(warning) ⇒ Object
48 49 50 |
# File 'lib/brakeman_translate_checkstyle_format/translate.rb', line 48 def self.(warning) "[#{warning['confidence']}][#{warning['warning_type']}] #{warning['message']}\n#{warning['link']}" end |
.set_dummy(json, checkstyle) ⇒ Object
40 41 42 43 44 45 46 |
# File 'lib/brakeman_translate_checkstyle_format/translate.rb', line 40 def self.set_dummy(json, checkstyle) checkstyle.add_element('file', 'name' => '' ) checkstyle end |
Instance Method Details
#parse(json) ⇒ Object
6 7 8 9 |
# File 'lib/brakeman_translate_checkstyle_format/translate.rb', line 6 def parse(json) JSON .parse(json) end |
#trans(json) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/brakeman_translate_checkstyle_format/translate.rb', line 11 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.(warning) ) end doc end |