class RSpectre::Offense
Constants
- DESCRIPTIONS
Public Class Methods
parse(type, node)
click to toggle source
# File lib/rspectre/offense.rb, line 14 def self.parse(type, node) new( file: node.file, line: node.line, source_line: node.source_line, start_column: node.start_column, end_column: node.end_column, type: type ) end
Public Instance Methods
description()
click to toggle source
rubocop:enable Layout/IndentHeredoc
# File lib/rspectre/offense.rb, line 40 def description DESCRIPTIONS.fetch(type) end
to_s()
click to toggle source
rubocop:disable Layout/IndentHeredoc
# File lib/rspectre/offense.rb, line 30 def to_s <<~DOC #{source_id}: #{offense_type}: #{description} #{source_line} #{highlight} DOC end
warn()
click to toggle source
# File lib/rspectre/offense.rb, line 25 def warn puts to_s end
Private Instance Methods
carets(n)
click to toggle source
# File lib/rspectre/offense.rb, line 58 def carets(n) Color.yellow('^' * n) end
highlight()
click to toggle source
# File lib/rspectre/offense.rb, line 54 def highlight ' ' * (start_column - 1) + carets(end_column - start_column) end
offense_type()
click to toggle source
# File lib/rspectre/offense.rb, line 50 def offense_type Color.yellow(type) end
source_id()
click to toggle source
# File lib/rspectre/offense.rb, line 46 def source_id Color.light_blue("#{file}:#{line}:#{start_column}") end