Class: Shirobai::Cop::Rails::ApplicationJob
- Inherits:
-
RuboCop::Cop::Base
- Object
- RuboCop::Cop::Base
- Shirobai::Cop::Rails::ApplicationJob
- Extended by:
- RuboCop::Cop::AutoCorrector, RuboCop::Cop::TargetRailsVersion
- Includes:
- BundleEligible
- Defined in:
- lib/shirobai/cop/rails/application_job.rb
Overview
Drop-in Rust reimplementation of Rails/ApplicationJob
(rubocop-rails 2.35.5). See ApplicationRecord for the shared
EnforceSuperclass semantics and offense/autocorrect ranges. Gated on
requires_gem('railties', '>= 5.0') like stock.
(Stock defines an explicit autocorrect(node) returning
corrector.replace(node, SUPERCLASS); the other three cops reach the
same replacement through the AutoCorrector block. Both collapse to
"replace the offense range with the superclass name", which is what
the shared wrapper corrector does here.)
Constant Summary collapse
- MSG =
"Jobs should subclass `ApplicationJob`."- SUPERCLASS =
"ApplicationJob"
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.badge ⇒ Object
27 |
# File 'lib/shirobai/cop/rails/application_job.rb', line 27 def self.badge = RuboCop::Cop::Badge.parse(cop_name) |
.bundle_args(_config) ⇒ Object
29 30 31 |
# File 'lib/shirobai/cop/rails/application_job.rb', line 29 def self.bundle_args(_config) [] end |
.cop_name ⇒ Object
26 |
# File 'lib/shirobai/cop/rails/application_job.rb', line 26 def self.cop_name = "Rails/ApplicationJob" |
Instance Method Details
#on_new_investigation ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/shirobai/cop/rails/application_job.rb', line 33 def on_new_investigation buffer = processed_source.buffer source = bundle_eligible? ? processed_source.raw_source : buffer.source off = SourceOffsets.for(source) resolved_offenses.each do |start_offset, end_offset| range = Parser::Source::Range.new(buffer, off[start_offset], off[end_offset]) add_offense(range, message: MSG) do |corrector| corrector.replace(range, self.class::SUPERCLASS) end end end |