Exception: RuboCop::ErrorWithAnalyzedFileLocation

Inherits:
Error
  • Object
show all
Defined in:
lib/rubocop/error.rb

Overview

A wrapper to display errored location of analyzed file.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(cause:, node:, cop:) ⇒ ErrorWithAnalyzedFileLocation

Returns a new instance of ErrorWithAnalyzedFileLocation.



14
15
16
17
18
# File 'lib/rubocop/error.rb', line 14

def initialize(cause:, node:, cop:)
  @cause = cause
  @cop = cop
  @location = node.is_a?(RuboCop::AST::Node) ? node.loc : node
end

Instance Attribute Details

#causeObject (readonly)

Returns the value of attribute cause.



20
21
22
# File 'lib/rubocop/error.rb', line 20

def cause
  @cause
end

#copObject (readonly)

Returns the value of attribute cop.



20
21
22
# File 'lib/rubocop/error.rb', line 20

def cop
  @cop
end

Instance Method Details

#columnObject



26
27
28
# File 'lib/rubocop/error.rb', line 26

def column
  @location&.column
end

#lineObject



22
23
24
# File 'lib/rubocop/error.rb', line 22

def line
  @location&.line
end

#messageObject



30
31
32
# File 'lib/rubocop/error.rb', line 30

def message
  "cause: #{cause.inspect}"
end