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 = public_send(attribute) <=> other.public_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|
    public_send(attribute) == other.public_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 correctable?

Returns:
  • (Boolean) -

Other tags:
    Api: - public
def correctable?
  @status != :unsupported
end

def corrected?

Returns:
  • (Boolean) -

Other tags:
    Api: - public
def corrected?
  @status == :corrected || @status == :corrected_with_todo
end

def corrected_with_todo?

Returns:
  • (Boolean) -

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

def disabled?

Returns:
  • (Boolean) -

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

def first_line

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

def hash

def hash
  COMPARISON_ATTRIBUTES.map { |attribute| public_send(attribute) }.hash
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, # rubocop:disable Metrics/ParameterLists

Other tags:
    Api: - private
def initialize(severity, location, message, cop_name, # rubocop:disable Metrics/ParameterLists
               status = :uncorrected, corrector = nil)
  @severity = RuboCop::Cop::Severity.new(severity)
  @location = location
  @message = message.freeze
  @cop_name = cop_name.freeze
  @status = status
  @corrector = corrector
  freeze
end

def last_column

Other tags:
    Api: - private
def last_column
  location.last_column
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('%<severity>s:%3<line>d:%3<column>d: %<message>s',
         severity: severity.code, line: line,
         column: real_column, message: message)
end