Sha256: 1c73fb038152b7fdd1865848f5ecd99823bc13fa662fe9a5a8b75f1906f66b61
Contents?: true
Size: 1.08 KB
Versions: 5
Compression:
Stored size: 1.08 KB
Contents
# frozen_string_literal: true module SlimLint # Outputs report as a JSON document. class Reporter::JsonReporter < Reporter def display_report(report) lints = report.lints grouped = lints.group_by(&:filename) report_hash = { metadata: metadata, files: grouped.map { |l| map_file(l) }, summary: { offense_count: lints.length, target_file_count: grouped.length, inspected_file_count: report.files.length } } log.log report_hash.to_json end private def metadata { slim_lint_version: SlimLint::VERSION, ruby_engine: RUBY_ENGINE, ruby_patchlevel: RUBY_PATCHLEVEL.to_s, ruby_platform: RUBY_PLATFORM } end def map_file(file) { path: file.first, offenses: file.last.map { |o| map_offense(o) } } end def map_offense(offense) { severity: offense.severity, message: offense.message, location: offense.location.as_json, cop_name: offense.name } end end end
Version data entries
5 entries across 5 versions & 1 rubygems