Class: Templatecop::TemplateOffenseCollector
- Inherits:
-
Object
- Object
- Templatecop::TemplateOffenseCollector
- Defined in:
- lib/templatecop/template_offense_collector.rb
Overview
Collect RuboCop offenses from Template code.
Instance Method Summary collapse
- #call ⇒ Array<Templatecop::Offense>
-
#initialize(autocorrect:, debug:, file_path:, rubocop_config:, ruby_extractor:, source:) ⇒ TemplateOffenseCollector
constructor
A new instance of TemplateOffenseCollector.
Constructor Details
#initialize(autocorrect:, debug:, file_path:, rubocop_config:, ruby_extractor:, source:) ⇒ TemplateOffenseCollector
Returns a new instance of TemplateOffenseCollector.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/templatecop/template_offense_collector.rb', line 12 def initialize( autocorrect:, debug:, file_path:, rubocop_config:, ruby_extractor:, source: ) @autocorrect = autocorrect @debug = debug @file_path = file_path @rubocop_config = rubocop_config @ruby_extractor = ruby_extractor @source = source end |
Instance Method Details
#call ⇒ Array<Templatecop::Offense>
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/templatecop/template_offense_collector.rb', line 29 def call snippets.flat_map do |snippet| RubyOffenseCollector.new( autocorrect: @autocorrect, debug: @debug, file_path: @file_path, rubocop_config: @rubocop_config, source: snippet[:code] ).call.map do |rubocop_offense| Offense.new( file_path: @file_path, offset: snippet[:offset], rubocop_offense: rubocop_offense, source: @source ) end end end |