Module: SwiftlintTranslateCheckstyleFormat::Translate
- Included in:
- CLI
- Defined in:
- lib/swiftlint_translate_checkstyle_format/translate.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.add_dummy(checkstyle) ⇒ Object
34 35 36 37 38 39 40 |
# File 'lib/swiftlint_translate_checkstyle_format/translate.rb', line 34 def self.add_dummy(checkstyle) checkstyle.add_element('file', 'name' => '' ) checkstyle end |
.create_message(result) ⇒ Object
42 43 44 |
# File 'lib/swiftlint_translate_checkstyle_format/translate.rb', line 42 def self.(result) "[#{result['severity']}][#{result['rule_id']}] #{result['type']}\n#{result['reason']}" end |
Instance Method Details
#parse(str) ⇒ Object
6 7 8 |
# File 'lib/swiftlint_translate_checkstyle_format/translate.rb', line 6 def parse(str) JSON.load(str) end |
#trans(json) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/swiftlint_translate_checkstyle_format/translate.rb', line 10 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' => result['file'] ) file.add_element('error', 'line' => result['line'], 'severity' => 'error', 'message' => SwiftlintTranslateCheckstyleFormat::Translate.(result) ) end doc end |