Class: RuboCop::Cop::Neeto::DeprecatedJobBaseClass
- Inherits:
-
Base
- Object
- Base
- RuboCop::Cop::Neeto::DeprecatedJobBaseClass
- Defined in:
- lib/rubocop/cop/neeto/deprecated_job_base_class.rb
Overview
The legacy ‘NeetoCommonsBackend::BaseJobs::*` base classes have been replaced with latency-based job classes such as `LatencyBasedJobs::Within5Seconds`, `LatencyBasedJobs::Within1Minute`, `LatencyBasedJobs::Within5Minutes`, and `LatencyBasedJobs::Within1Hour`. This cop prevents new jobs from inheriting directly from the legacy Neeto Commons base classes.
Constant Summary collapse
- LEGACY_SUPERCLASSES =
{ "NeetoCommonsBackend::BaseJobs::Urgent" => "Use `LatencyBasedJobs::Within5Seconds` instead.", "NeetoCommonsBackend::BaseJobs::Auth" => "Use `LatencyBasedJobs::Within1Minute` instead.", "NeetoCommonsBackend::BaseJobs::Default" => "Use `LatencyBasedJobs::Within1Minute` or `LatencyBasedJobs::Within5Minutes` based on the job's SLA.", "NeetoCommonsBackend::BaseJobs::Low" => "Use `LatencyBasedJobs::Within1Hour` instead.", "NeetoCommonsBackend::BaseJobs::Base" => "Use a latency-based job base class instead, for example `LatencyBasedJobs::Within5Seconds`, `LatencyBasedJobs::Within1Minute`, `LatencyBasedJobs::Within5Minutes`, or `LatencyBasedJobs::Within1Hour`." }.freeze
- MSG =
"Do not inherit jobs directly from `%<superclass>s`. %<replacement>s"
Instance Method Summary collapse
Instance Method Details
#on_class(node) ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/rubocop/cop/neeto/deprecated_job_base_class.rb', line 48 def on_class(node) return if allowed_file_path? superclass = node.parent_class return unless superclass&.const_type? superclass_name = superclass.const_name replacement = LEGACY_SUPERCLASSES[superclass_name] return unless replacement add_offense(superclass, message: format(MSG, superclass: superclass_name, replacement:)) end |