Class: HamlLint::Linter::RuboCop

Inherits:
HamlLint::Linter show all
Includes:
HamlLint::LinterRegistry
Defined in:
lib/haml_lint/linter/rubocop.rb

Overview

Runs RuboCop on Ruby code contained within HAML templates.

Constant Summary collapse

SEVERITY_MAP =

Maps the ::RuboCop::Cop::Severity levels to our own levels.

{
  error: :error,
  fatal: :error,

  convention: :warning,
  refactor: :warning,
  warning: :warning,
}.freeze

Instance Attribute Summary

Attributes inherited from HamlLint::Linter

#lints

Instance Method Summary collapse

Methods included from HamlLint::LinterRegistry

extract_linters_from, included

Methods inherited from HamlLint::Linter

#initialize, #name, #run

Methods included from HamlVisitor

#visit, #visit_children

Constructor Details

This class inherits a constructor from HamlLint::Linter

Instance Method Details

#visit_root(_node) ⇒ Object


21
22
23
24
25
26
27
28
# File 'lib/haml_lint/linter/rubocop.rb', line 21

def visit_root(_node)
  extractor = HamlLint::RubyExtractor.new
  extracted_source = extractor.extract(document)

  return if extracted_source.source.empty?

  find_lints(extracted_source.source, extracted_source.source_map)
end