Sha256: 9138e8f94705386984596d3d222644d3f5d6be39673918e989352ed3a4eef19e
Contents?: true
Size: 971 Bytes
Versions: 14
Compression:
Stored size: 971 Bytes
Contents
# frozen_string_literal: true require 'json' module ThemeCheck class JsonPrinter def initialize(out_stream = STDOUT) @out = out_stream end def print(offenses) json = offenses_by_path(offenses) @out.puts JSON.dump(json) end def offenses_by_path(offenses) offenses .map(&:to_h) .group_by { |offense| offense[:path] } .map do |(path, path_offenses)| { path: path, offenses: path_offenses.map { |offense| offense.filter { |k, _v| k != :path } }, errorCount: path_offenses.count { |offense| offense[:severity] == Check::SEVERITY_VALUES[:error] }, suggestionCount: path_offenses.count { |offense| offense[:severity] == Check::SEVERITY_VALUES[:suggestion] }, styleCount: path_offenses.count { |offense| offense[:severity] == Check::SEVERITY_VALUES[:style] }, } end .sort_by { |o| o[:path] } end end end
Version data entries
14 entries across 14 versions & 1 rubygems