lib/rubocop/formatter/html_formatter.rb in rubocop-0.35.1 vs lib/rubocop/formatter/html_formatter.rb in rubocop-0.36.0
- old
+ new
@@ -1,6 +1,7 @@
# encoding: utf-8
+# frozen_string_literal: true
require 'cgi'
require 'erb'
require 'ostruct'
require 'base64'
@@ -11,13 +12,25 @@
# This formatter saves the output as a html file.
class HTMLFormatter < BaseFormatter
TEMPLATE_PATH =
File.expand_path('../../../../assets/output.html.erb', __FILE__)
+ Color = Struct.new(:red, :green, :blue, :alpha) do
+ def to_s
+ "rgba(#{values.join(', ')})"
+ end
+
+ def fade_out(amount)
+ dup.tap do |color|
+ color.alpha -= amount
+ end
+ end
+ end
+
attr_reader :files, :summary
- def initialize(output)
+ def initialize(output, options = {})
super
@files = []
@summary = OpenStruct.new(offense_count: 0)
end
@@ -44,32 +57,20 @@
html = erb.result(context.binding)
output.write html
end
- Color = Struct.new(:red, :green, :blue, :alpha) do
- def to_s
- "rgba(#{values.join(', ')})"
- end
-
- def fade_out(amount)
- dup.tap do |color|
- color.alpha -= amount
- end
- end
- end
-
# This class provides helper methods used in the ERB template.
class ERBContext
include PathUtil, TextUtil
SEVERITY_COLORS = {
refactor: Color.new(0xED, 0x9C, 0x28, 1.0),
convention: Color.new(0xED, 0x9C, 0x28, 1.0),
warning: Color.new(0x96, 0x28, 0xEF, 1.0),
error: Color.new(0xD2, 0x32, 0x2D, 1.0),
fatal: Color.new(0xD2, 0x32, 0x2D, 1.0)
- }
+ }.freeze
LOGO_IMAGE_PATH =
File.expand_path('../../../../assets/logo.png', __FILE__)
attr_reader :files, :summary