Sha256: 3fbf461e0ebb345d98abfe82c770115c918865b533cb3c13b336c354d5b1c233
Contents?: true
Size: 991 Bytes
Versions: 25
Compression:
Stored size: 991 Bytes
Contents
# frozen_string_literal: true require 'json' module PlatformosCheck 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:, 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] || Pathname.new('') } end end end
Version data entries
25 entries across 25 versions & 1 rubygems