Class: Pronto::Rubocop::PatchCop
- Inherits:
-
Object
- Object
- Pronto::Rubocop::PatchCop
- Defined in:
- lib/pronto/rubocop/patch_cop.rb
Instance Attribute Summary collapse
-
#runner ⇒ Object
readonly
Returns the value of attribute runner.
Instance Method Summary collapse
-
#initialize(patch, runner) ⇒ PatchCop
constructor
A new instance of PatchCop.
- #messages ⇒ Object
- #processed_source ⇒ Object
- #registry ⇒ Object
- #rubocop_config ⇒ Object
Constructor Details
#initialize(patch, runner) ⇒ PatchCop
Returns a new instance of PatchCop.
8 9 10 11 |
# File 'lib/pronto/rubocop/patch_cop.rb', line 8 def initialize(patch, runner) @patch = patch @runner = runner end |
Instance Attribute Details
#runner ⇒ Object (readonly)
Returns the value of attribute runner.
6 7 8 |
# File 'lib/pronto/rubocop/patch_cop.rb', line 6 def runner @runner end |
Instance Method Details
#messages ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/pronto/rubocop/patch_cop.rb', line 13 def return [] unless valid? offenses .map { |offense| (patch, offense) } .compact end |
#processed_source ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/pronto/rubocop/patch_cop.rb', line 21 def processed_source @processed_source ||= begin processed_source = ::RuboCop::ProcessedSource.from_file( path, rubocop_config.target_ruby_version ) processed_source.registry = registry if processed_source.respond_to?(:registry=) processed_source.config = rubocop_config if processed_source.respond_to?(:config=) processed_source end end |
#registry ⇒ Object
33 34 35 |
# File 'lib/pronto/rubocop/patch_cop.rb', line 33 def registry @registry ||= ::RuboCop::Cop::Registry.new(RuboCop::Cop::Cop.all) end |
#rubocop_config ⇒ Object
37 38 39 40 41 42 43 |
# File 'lib/pronto/rubocop/patch_cop.rb', line 37 def rubocop_config @rubocop_config ||= begin store = ::RuboCop::ConfigStore.new store. = ENV['RUBOCOP_CONFIG'] if ENV['RUBOCOP_CONFIG'] store.for(path) end end |