rubocop-neeto 0.1.13 → 0.1.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8184d728fee43af3b4bcb59ccf8ecc827ed5c2b7d351dcc352accc96c5747668
4
- data.tar.gz: e055d4c63eadc8d751abba0856f443300f124f2c7d8a29f2983f7b217fa77ce4
3
+ metadata.gz: adbaf8298c1804456d5050900f7e9c1d0688ad5f10e8b66c3db71bf90ad4fd81
4
+ data.tar.gz: 7f8b07c600c15ae128f6f11586f349aa6376be85fdeda1105568873a518228e5
5
5
  SHA512:
6
- metadata.gz: 198e1dcb6d07c4ad72761b3d950fa72e27e3cec5717dc5e20c536732b8852fa1dce95e660d507b83193f5a2a2c7a6fdf3a2a49b12950fe4cbacfaf36e0c87749
7
- data.tar.gz: 7c1ed69c05f6f73d3e1ce1deab02192720af603dd284368929e118afdd2d7608d3386f8720afd84058c82d5b1904e31be6304b83b26014a564272f36b771ab68
6
+ metadata.gz: ac72b53c76cb5e555c22a7a33af51a2de10bc3b552e0d6f0bbe57527c3023088f08342744ccb99636a0bca4f4f1a1a8b0c40bf08f6a47a3ea976d21d3a56da38
7
+ data.tar.gz: 52b490198a4a344ce20397f18bd5518ec76261673f32bfe83ec2236e23f40045a8c4a9cff6fabbdead8d36e7661671e8b0e075a27facac892b9a9be28db93810
data/README.md CHANGED
@@ -5,6 +5,7 @@
5
5
  1. [Neeto/UnsafeTableDeletion](https://rubocop-neeto.neetodeployapp.com/docs/RuboCop/Cop/Neeto/UnsafeTableDeletion)
6
6
  2. [Neeto/UnsafeColumnDeletion](https://rubocop-neeto.neetodeployapp.com/docs/RuboCop/Cop/Neeto/UnsafeColumnDeletion)
7
7
  3. [Neeto/DirectEnvAccess](https://rubocop-neeto.neetodeployapp.com/docs/RuboCop/Cop/Neeto/DirectEnvAccess)
8
+ 4. [Neeto/DeprecatedJobBaseClass](https://rubocop-neeto.neetodeployapp.com/docs/RuboCop/Cop/Neeto/DeprecatedJobBaseClass)
8
9
 
9
10
  ## Installation
10
11
 
data/config/default.yml CHANGED
@@ -37,3 +37,19 @@ Neeto/DirectEnvAccess:
37
37
  VersionAdded: '0.1'
38
38
  Include:
39
39
  - app/**/*.rb
40
+
41
+ Neeto/DeprecatedJobBaseClass:
42
+ Description: >-
43
+ Jobs should not inherit directly from the legacy
44
+ `NeetoCommonsBackend::BaseJobs::*` base classes. Use latency-based job
45
+ classes such as `LatencyBasedJobs::Within5Seconds`,
46
+ `LatencyBasedJobs::Within1Minute`, `LatencyBasedJobs::Within5Minutes`,
47
+ or `LatencyBasedJobs::Within1Hour` instead.
48
+ Enabled: true
49
+ Severity: refactor
50
+ VersionAdded: '0.1'
51
+ Include:
52
+ - app/jobs/**/*.rb
53
+ - app/workers/**/*.rb
54
+ - test/dummy/app/jobs/**/*.rb
55
+ - test/dummy/app/workers/**/*.rb
@@ -0,0 +1,72 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RuboCop
4
+ module Cop
5
+ module Neeto
6
+ # The legacy `NeetoCommonsBackend::BaseJobs::*` base classes have been
7
+ # replaced with latency-based job classes such as
8
+ # `LatencyBasedJobs::Within5Seconds`, `LatencyBasedJobs::Within1Minute`,
9
+ # `LatencyBasedJobs::Within5Minutes`, and `LatencyBasedJobs::Within1Hour`.
10
+ # This cop prevents new jobs from inheriting directly from the legacy
11
+ # Neeto Commons base classes.
12
+ #
13
+ # @example DeprecatedJobBaseClass: true (default)
14
+ # # bad
15
+ # class ExportJob < NeetoCommonsBackend::BaseJobs::Default
16
+ # end
17
+ #
18
+ # # bad
19
+ # class SyncWebhookJob < NeetoCommonsBackend::BaseJobs::Urgent
20
+ # end
21
+ #
22
+ # # good
23
+ # class ExportJob < LatencyBasedJobs::Within5Minutes
24
+ # end
25
+ #
26
+ # # good
27
+ # class SyncWebhookJob < LatencyBasedJobs::Within5Seconds
28
+ # end
29
+ #
30
+ # # good
31
+ # # Defining the latency classes themselves
32
+ # module LatencyBasedJobs
33
+ # class Within5Seconds < NeetoCommonsBackend::BaseJobs::Base
34
+ # end
35
+ # end
36
+ #
37
+ class DeprecatedJobBaseClass < Base
38
+ LEGACY_SUPERCLASSES = {
39
+ "NeetoCommonsBackend::BaseJobs::Urgent" => "Use `LatencyBasedJobs::Within5Seconds` instead.",
40
+ "NeetoCommonsBackend::BaseJobs::Auth" => "Use `LatencyBasedJobs::Within1Minute` instead.",
41
+ "NeetoCommonsBackend::BaseJobs::Default" => "Use `LatencyBasedJobs::Within1Minute` or `LatencyBasedJobs::Within5Minutes` based on the job's SLA.",
42
+ "NeetoCommonsBackend::BaseJobs::Low" => "Use `LatencyBasedJobs::Within1Hour` instead.",
43
+ "NeetoCommonsBackend::BaseJobs::Base" => "Use a latency-based job base class instead, for example `LatencyBasedJobs::Within5Seconds`, `LatencyBasedJobs::Within1Minute`, `LatencyBasedJobs::Within5Minutes`, or `LatencyBasedJobs::Within1Hour`."
44
+ }.freeze
45
+
46
+ MSG = "Do not inherit jobs directly from `%<superclass>s`. %<replacement>s"
47
+
48
+ def on_class(node)
49
+ return if allowed_file_path?
50
+
51
+ superclass = node.parent_class
52
+ return unless superclass&.const_type?
53
+
54
+ superclass_name = superclass.const_name
55
+ replacement = LEGACY_SUPERCLASSES[superclass_name]
56
+ return unless replacement
57
+
58
+ add_offense(superclass, message: format(MSG, superclass: superclass_name, replacement:))
59
+ end
60
+
61
+ private
62
+
63
+ def allowed_file_path?
64
+ file_path = processed_source.file_path.to_s
65
+
66
+ file_path.end_with?("app/jobs/concerns/latency_based_jobs.rb") ||
67
+ file_path.match?(%r{(?:\A|/)app/jobs/neeto_commons_backend/base_jobs/})
68
+ end
69
+ end
70
+ end
71
+ end
72
+ end
@@ -3,3 +3,4 @@
3
3
  require_relative "neeto/unsafe_table_deletion"
4
4
  require_relative "neeto/unsafe_column_deletion"
5
5
  require_relative "neeto/direct_env_access"
6
+ require_relative "neeto/deprecated_job_base_class"
@@ -2,6 +2,6 @@
2
2
 
3
3
  module RuboCop
4
4
  module Neeto
5
- VERSION = "0.1.13"
5
+ VERSION = "0.1.15"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubocop-neeto
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.13
4
+ version: 0.1.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - Abhay V Ashokan
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2026-02-10 00:00:00.000000000 Z
11
+ date: 2026-04-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubocop
@@ -35,6 +35,7 @@ files:
35
35
  - Rakefile
36
36
  - config/default.yml
37
37
  - lib/rubocop-neeto.rb
38
+ - lib/rubocop/cop/neeto/deprecated_job_base_class.rb
38
39
  - lib/rubocop/cop/neeto/direct_env_access.rb
39
40
  - lib/rubocop/cop/neeto/unsafe_column_deletion.rb
40
41
  - lib/rubocop/cop/neeto/unsafe_table_deletion.rb