File: code-climate-json-to-html.rb

package info (click to toggle)
tango 10.0.2%2Bdfsg1-2%2Bdeb13u1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 89,936 kB
  • sloc: cpp: 201,786; sh: 1,645; python: 953; java: 800; perl: 467; javascript: 447; xml: 325; makefile: 269; sql: 72; ruby: 24
file content (33 lines) | stat: -rw-r--r-- 821 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#! /usr/bin/env ruby
# frozen_string_literal: true

require 'erb'
require 'json'
require 'cc/analyzer/filesystem'
require 'cc/analyzer/source_buffer'
require 'cc/analyzer/formatters/formatter'
require 'cc/analyzer/formatters/html_formatter'

# Limit the number of the issues to not crash the browser.
ISSUES_LIMIT = 3000

class JSONToHTMLEngine # rubocop:disable Style/Documentation
  def name
    'json-to-html'
  end
end

source_directory = ARGV[0] || Dir.pwd
filesystem = CC::Analyzer::Filesystem.new(source_directory)
formatter = CC::Analyzer::Formatters::HTMLFormatter.new(filesystem)

data = JSON.parse!($stdin.read)

formatter.started
formatter.engine_running(JSONToHTMLEngine.new) do
  data.take(ISSUES_LIMIT).each do |entry|
    formatter.write(JSON.generate(entry))
  end
end
formatter.finished
formatter.close