class RuboCop::Formatter::HTMLFormatter::ERBContext
This class provides helper methods used in the ERB template.
Constants
- LOGO_IMAGE_PATH
- SEVERITY_COLORS
Attributes
files[R]
summary[R]
Public Class Methods
new(files, summary)
click to toggle source
# File lib/rubocop/formatter/html_formatter.rb, line 78 def initialize(files, summary) @files = files.sort_by(&:path) @summary = summary end
Public Instance Methods
base64_encoded_logo_image()
click to toggle source
# File lib/rubocop/formatter/html_formatter.rb, line 125 def base64_encoded_logo_image image = File.read(LOGO_IMAGE_PATH, binmode: true) Base64.encode64(image) end
binding()
click to toggle source
Make Kernel#binding public. rubocop:disable Lint/UselessMethodDefinition
Calls superclass method
# File lib/rubocop/formatter/html_formatter.rb, line 85 def binding super end
decorated_message(offense)
click to toggle source
rubocop:enable Lint/UselessMethodDefinition
# File lib/rubocop/formatter/html_formatter.rb, line 90 def decorated_message(offense) offense.message.gsub(/`(.+?)`/) { "<code>#{Regexp.last_match(1)}</code>" } end
escape(string)
click to toggle source
# File lib/rubocop/formatter/html_formatter.rb, line 121 def escape(string) CGI.escapeHTML(string) end
highlight_source_tag(offense)
click to toggle source
# File lib/rubocop/formatter/html_formatter.rb, line 101 def highlight_source_tag(offense) "<span class=\"highlight #{offense.severity}\">" \ "#{escape(offense.highlighted_area.source)}" \ '</span>' end
highlighted_source_line(offense)
click to toggle source
# File lib/rubocop/formatter/html_formatter.rb, line 94 def highlighted_source_line(offense) source_before_highlight(offense) + highlight_source_tag(offense) + source_after_highlight(offense) + possible_ellipses(offense.location) end
possible_ellipses(location)
click to toggle source
# File lib/rubocop/formatter/html_formatter.rb, line 117 def possible_ellipses(location) location.single_line? ? '' : " #{ELLIPSES}" end
source_after_highlight(offense)
click to toggle source
# File lib/rubocop/formatter/html_formatter.rb, line 112 def source_after_highlight(offense) source_line = offense.location.source_line escape(source_line[offense.highlighted_area.end_pos..]) end
source_before_highlight(offense)
click to toggle source
# File lib/rubocop/formatter/html_formatter.rb, line 107 def source_before_highlight(offense) source_line = offense.location.source_line escape(source_line[0...offense.highlighted_area.begin_pos]) end