class RuboCop::Cop::Offense

An offense represents a style violation detected by RuboCop.

def <=>(other)

Returns:
  • (Integer) -

Other tags:
    Api: - public
def <=>(other)
  COMPARISON_ATTRIBUTES.each do |attribute|
    result = send(attribute) <=> other.send(attribute)
    return result unless result.zero?
  end
  0
end

def ==(other)

Returns:
  • (Boolean) -

Other tags:
    Api: - public
def ==(other)
  COMPARISON_ATTRIBUTES.all? do |attribute|
    send(attribute) == other.send(attribute)
  end
end

def column

Other tags:
    Api: - private
def column
  location.column
end

def column_length

Other tags:
    Api: - private
def column_length
  if first_line == last_line
    column_range.count
  else
    source_line.length - column
  end
end

def column_range

Other tags:
    Api: - private
def column_range
  location.column_range
end

def corrected

Returns:
  • (Boolean) -

Other tags:
    Api: - public
def corrected
  @status == :unsupported ? false : @status == :corrected
end

def disabled?

Returns:
  • (Boolean) -

Other tags:
    Api: - public
def disabled?
  @status == :disabled
end

def first_line

Other tags:
    Api: - private
def first_line
  location.first_line
end

def hash

def hash
  COMPARISON_ATTRIBUTES.reduce(0) do |hash, attribute|
    hash ^ send(attribute).hash
  end
end

def highlighted_area

Returns:
  • (Parser::Source::Range) -

Other tags:
    Api: - public
def highlighted_area
  Parser::Source::Range.new(source_line,
                            column,
                            column + column_length)
end

def initialize(severity, location, message, cop_name,

Other tags:
    Api: - private
def initialize(severity, location, message, cop_name,
               status = :uncorrected)
  @severity = RuboCop::Cop::Severity.new(severity)
  @location = location
  @message = message.freeze
  @cop_name = cop_name.freeze
  @status = status
  freeze
end

def last_line

Other tags:
    Api: - private
def last_line
  location.last_line
end

def line

Other tags:
    Api: - private
def line
  location.line
end

def real_column

Other tags:
    Api: - private
def real_column
  column + 1
end

def source_line

Other tags:
    Api: - private
def source_line
  location.source_line
end

def to_s

Other tags:
    Api: - private
def to_s
  format('%s:%3d:%3d: %s',
         severity.code, line, real_column, message)
end