class Git::Cop::Reporters::Cop
Reports issues related to a single cop.
Attributes
colorizer[R]
cop[R]
issue[R]
Public Class Methods
new(cop, colorizer: Pastel.new)
click to toggle source
# File lib/git/cop/reporters/cop.rb, line 10 def initialize cop, colorizer: Pastel.new @cop = cop @issue = cop.issue @colorizer = colorizer end
Public Instance Methods
to_s()
click to toggle source
# File lib/git/cop/reporters/cop.rb, line 16 def to_s colorizer.public_send color, message end
Private Instance Methods
affected_lines()
click to toggle source
# File lib/git/cop/reporters/cop.rb, line 46 def affected_lines issue.fetch(:lines, []).reduce("") { |lines, line| lines + Line.new(line).to_s } end
color()
click to toggle source
# File lib/git/cop/reporters/cop.rb, line 38 def color case cop.severity when :warn then :yellow when :error then :red else :white end end
message()
click to toggle source
# File lib/git/cop/reporters/cop.rb, line 24 def message " #{cop.class.label}#{severity_suffix}. " \ "#{issue.fetch :hint}\n" \ "#{affected_lines}" end
severity_suffix()
click to toggle source
# File lib/git/cop/reporters/cop.rb, line 30 def severity_suffix case cop.severity when :warn then " Warning" when :error then " Error" else "" end end