Sha256: 1eb8d7354d89746d514cc0ce825a2653d997266b047316163333c8ca8d3da239
Contents?: true
Size: 893 Bytes
Versions: 1
Compression:
Stored size: 893 Bytes
Contents
# frozen_string_literal: true require 'json' module ThemeCheck class JsonPrinter def print(offenses) json = offenses_by_path(offenses) 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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
theme-check-1.5.0 | lib/theme_check/json_printer.rb |