Class: Rubocop::Cop::Lint::Syntax

Inherits:
Cop
  • Object
show all
Defined in:
lib/rubocop/cop/lint/syntax.rb

Overview

This cop actually inspects nothing, just repacks Parser's diagnostics into RuboCop's offences. The purpose of this cop is to support disabling Syntax offences with config or inline comments by conforming to the cop framework.

Constant Summary

Constants inherited from Cop

Cop::OPERATOR_METHODS

Instance Attribute Summary

Attributes inherited from Cop

#config, #corrections, #offences, #processed_source

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Cop

#add_offence, all, #autocorrect?, #convention, #cop_config, cop_name, #cop_name, cop_type, #debug?, #ignore_node, inherited, #initialize, lint?, #message, non_rails, rails?, style?, #support_autocorrect?, #warning

Constructor Details

This class inherits a constructor from Rubocop::Cop::Cop

Class Method Details

.offence_from_diagnostic(diagnostic) ⇒ Object



17
18
19
20
21
22
23
24
# File 'lib/rubocop/cop/lint/syntax.rb', line 17

def self.offence_from_diagnostic(diagnostic)
  Offence.new(
    diagnostic.level,
    diagnostic.location,
    diagnostic.message,
    cop_name
  )
end

.offences_from_diagnostics(diagnostics) ⇒ Object



11
12
13
14
15
# File 'lib/rubocop/cop/lint/syntax.rb', line 11

def self.offences_from_diagnostics(diagnostics)
  diagnostics.map do |diagnostic|
    offence_from_diagnostic(diagnostic)
  end
end

Instance Method Details

#investigate(processed_source) ⇒ Object



26
27
28
29
30
# File 'lib/rubocop/cop/lint/syntax.rb', line 26

def investigate(processed_source)
  processed_source.diagnostics.each do |d|
    add_offence(d.level, nil, d.location, d.message)
  end
end