Class: Templatecop::RubyOffenseCollector
- Inherits:
-
Object
- Object
- Templatecop::RubyOffenseCollector
- Defined in:
- lib/templatecop/ruby_offense_collector.rb
Overview
Collect RuboCop offenses from Ruby code.
Instance Method Summary collapse
- #call ⇒ Array<RuboCop::Cop::Offense>
-
#initialize(autocorrect:, file_path:, rubocop_config:, source:, debug: false) ⇒ RubyOffenseCollector
constructor
A new instance of RubyOffenseCollector.
Constructor Details
#initialize(autocorrect:, file_path:, rubocop_config:, source:, debug: false) ⇒ RubyOffenseCollector
Returns a new instance of RubyOffenseCollector.
13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/templatecop/ruby_offense_collector.rb', line 13 def initialize( autocorrect:, file_path:, rubocop_config:, source:, debug: false ) @autocorrect = autocorrect @debug = debug @file_path = file_path @rubocop_config = rubocop_config @source = source end |
Instance Method Details
#call ⇒ Array<RuboCop::Cop::Offense>
28 29 30 31 32 33 |
# File 'lib/templatecop/ruby_offense_collector.rb', line 28 def call # Skip if invalid syntax Ruby code is given. (e.g. "- if a?") return [] unless rubocop_processed_source.valid_syntax? rubocop_team.investigate(rubocop_processed_source).offenses.reject(&:disabled?) end |