Class: RuboCop::Cop::Rails::ApplicationJob

Inherits:
Base
  • Object
show all
Extended by:
AutoCorrector, TargetRailsVersion
Includes:
EnforceSuperclass
Defined in:
lib/rubocop/cop/rails/application_job.rb

Overview

Checks that jobs subclass ‘ApplicationJob` with Rails 5.0.

Examples:


# good
class Rails5Job < ApplicationJob
  # ...
end

# bad
class Rails4Job < ActiveJob::Base
  # ...
end

Constant Summary collapse

MSG =
'Jobs should subclass `ApplicationJob`.'
SUPERCLASS =
'ApplicationJob'
BASE_PATTERN =
'(const (const {nil? cbase} :ActiveJob) :Base)'

Constants included from TargetRailsVersion

TargetRailsVersion::TARGET_GEM_NAME, TargetRailsVersion::USES_REQUIRES_GEM_API

Instance Method Summary collapse

Methods included from TargetRailsVersion

minimum_target_rails_version, support_target_rails_version?

Methods included from EnforceSuperclass

included, #on_class, #on_send

Instance Method Details

#autocorrect(node) ⇒ Object

rubocop:enable Layout/ClassStructure



37
38
39
40
41
# File 'lib/rubocop/cop/rails/application_job.rb', line 37

def autocorrect(node)
  lambda do |corrector|
    corrector.replace(node, self.class::SUPERCLASS)
  end
end