Class: ERBLint::Linters::Rubocop
- Inherits:
-
ERBLint::Linter
- Object
- ERBLint::Linter
- ERBLint::Linters::Rubocop
- Includes:
- ERBLint::LinterRegistry
- Defined in:
- lib/erb_lint/linters/rubocop.rb
Overview
Run selected rubocop cops on Ruby code
Direct Known Subclasses
Defined Under Namespace
Classes: ConfigSchema
Constant Summary collapse
- SUFFIX_EXPR =
/[[:blank:]]*\Z/
- BLOCK_EXPR =
copied from Rails: action_view/template/handlers/erb/erubi.rb
/\s*((\s+|\))do|\{)(\s*\|[^|]*\|)?\s*\Z/
Constants included from ERBLint::LinterRegistry
ERBLint::LinterRegistry::CUSTOM_LINTERS_DIR
Instance Attribute Summary
Attributes inherited from ERBLint::Linter
Instance Method Summary collapse
- #autocorrect(processed_source, offense) ⇒ Object
-
#initialize(file_loader, config) ⇒ Rubocop
constructor
A new instance of Rubocop.
- #run(processed_source) ⇒ Object
Methods included from ERBLint::LinterRegistry
clear, find_by_name, included, linters, load_custom_linters
Methods inherited from ERBLint::Linter
#clear_offenses, #enabled?, #excludes_file?, inherited, #run_and_update_offense_status, support_autocorrect?
Constructor Details
#initialize(file_loader, config) ⇒ Rubocop
Returns a new instance of Rubocop.
25 26 27 28 29 30 31 |
# File 'lib/erb_lint/linters/rubocop.rb', line 25 def initialize(file_loader, config) super @only_cops = @config.only custom_config = config_from_path(@config.config_file_path) if @config.config_file_path custom_config ||= config_from_hash(@config.rubocop_config) @rubocop_config = ::RuboCop::ConfigLoader.merge_with_default(custom_config, "") end |
Instance Method Details
#autocorrect(processed_source, offense) ⇒ Object
40 41 42 43 44 45 46 47 48 49 |
# File 'lib/erb_lint/linters/rubocop.rb', line 40 def autocorrect(_processed_source, offense) return unless offense.context rubocop_correction = offense.context[:rubocop_correction] return unless rubocop_correction lambda do |corrector| corrector.import!(rubocop_correction, offset: offense.context[:offset]) end end |
#run(processed_source) ⇒ Object
33 34 35 36 37 |
# File 'lib/erb_lint/linters/rubocop.rb', line 33 def run(processed_source) descendant_nodes(processed_source).each do |erb_node| inspect_content(processed_source, erb_node) end end |