Class: ESLintRails::Warning

Inherits:
Object
  • Object
show all
Defined in:
lib/eslint-rails-ee/warning.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(filename, warning_hash) ⇒ Warning

Returns a new instance of Warning.



8
9
10
11
12
13
14
15
16
# File 'lib/eslint-rails-ee/warning.rb', line 8

def initialize(filename, warning_hash)
  @filename = filename
  @rule_id = warning_hash['ruleId'] || "unexpected error"
  @severity = warning_hash['severity']
  @message = warning_hash['message']
  @line = warning_hash['line']
  @column = warning_hash['column']
  @node_type = warning_hash['nodeType']
end

Instance Attribute Details

#columnObject (readonly)

Returns the value of attribute column.



3
4
5
# File 'lib/eslint-rails-ee/warning.rb', line 3

def column
  @column
end

#filenameObject (readonly)

Returns the value of attribute filename.



3
4
5
# File 'lib/eslint-rails-ee/warning.rb', line 3

def filename
  @filename
end

#lineObject (readonly)

Returns the value of attribute line.



3
4
5
# File 'lib/eslint-rails-ee/warning.rb', line 3

def line
  @line
end

#node_typeObject (readonly)

Returns the value of attribute node_type.



3
4
5
# File 'lib/eslint-rails-ee/warning.rb', line 3

def node_type
  @node_type
end

Instance Method Details

#locationObject



22
23
24
# File 'lib/eslint-rails-ee/warning.rb', line 22

def location
  "#{filename}:#{line}:#{column}"
end

#messageObject



30
31
32
# File 'lib/eslint-rails-ee/warning.rb', line 30

def message
  @message || 'N/A'
end

#rule_idObject



26
27
28
# File 'lib/eslint-rails-ee/warning.rb', line 26

def rule_id
  @rule_id || 'N/A'
end

#severityObject



18
19
20
# File 'lib/eslint-rails-ee/warning.rb', line 18

def severity
  SEVERITY[@severity-1]
end