gl_rubocop 0.5.4 → 0.5.5

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: cbecf0a138a66001d115607b6e635bda71eb4a2637c7eaa86b164807313efc8c
4
- data.tar.gz: a40a64ea1547488a822ed7f021c688da5187ec57dde140357d05b3f624c9bbfb
3
+ metadata.gz: 5609bd9d5a3b5e3fe6dded2031b9e86d4f51716b511a032205ed4e6564007c6a
4
+ data.tar.gz: 0b28be74b5a9a19773bdab6bec25f8dd4031eb7ed4dd53451af5609a330fb595
5
5
  SHA512:
6
- metadata.gz: 25d837867c4e28a5e2e7134db085a93b94392ceb783bd533240c04a9f582adbfc60033edd5fadce6b5bfa5ebf569728fd258b2394a8f4dff6c9128df44fca953
7
- data.tar.gz: 6af51558e77b72d5f791f51a5cb87f4a4fa51c953d08b69f9a4c1d87b6724cf5f9601a94e9b8f47f0ee6d06618a53e6c8bb50774cdd5796ddaebc59f98aafe4e
6
+ metadata.gz: fde9706801fcbd3f2eb95f1f02f8e85bda03a864a2e72e9b06ecf2b821b629f83e3b43cc6c8245db412afb30e0e425df79efb0bdfdd44b1b3ef34c66e7c52a9b
7
+ data.tar.gz: c9bb0a94e4bae6ea981de96f42bfe7d3ae69aef0703ce9afe35f7c53d6396bb381a689da7e8745365c34a3207a7fb836d0185680716458b4b656086d22dc0cfb
data/default.yml CHANGED
@@ -14,6 +14,7 @@ require:
14
14
  - ./lib/gl_rubocop/gl_cops/limit_flash_options.rb
15
15
  - ./lib/gl_rubocop/gl_cops/no_stubbing_env.rb
16
16
  - ./lib/gl_rubocop/gl_cops/no_stubbing_perform_async.rb
17
+ - ./lib/gl_rubocop/gl_cops/no_transaction_in_controllers.rb
17
18
  - ./lib/gl_rubocop/gl_cops/prevent_haml_files.rb
18
19
  - ./lib/gl_rubocop/gl_cops/rails_cache.rb
19
20
  - ./lib/gl_rubocop/gl_cops/sidekiq_inherits_from_sidekiq_job.rb
@@ -86,6 +87,12 @@ GLCops/NoStubbingPerformAsync:
86
87
  Include:
87
88
  - "**/*spec.rb"
88
89
 
90
+ GLCops/NoTransactionInControllers:
91
+ Enabled: true
92
+ Include:
93
+ - "app/controllers/**/*"
94
+ - "packs/**/app/controllers/**/*"
95
+
89
96
  GLCops/PreventHamlFiles:
90
97
  Enabled: true
91
98
 
@@ -0,0 +1,37 @@
1
+ module GLRubocop
2
+ module GLCops
3
+ # This cop bans the use of ActiveRecord transactions within controllers.
4
+ #
5
+ # Per our controller standards RFC, opening a database transaction in a controller
6
+ # entangles the networking layer with the database layer and violates separation of
7
+ # concerns. Transactional logic belongs in a GLCommand or service object.
8
+ #
9
+ # Good:
10
+ # # app/commands/transfer_funds.rb
11
+ # ActiveRecord::Base.transaction do
12
+ # # ...
13
+ # end
14
+ #
15
+ # Bad:
16
+ # # app/controllers/transfers_controller.rb
17
+ # ActiveRecord::Base.transaction do
18
+ # # ...
19
+ # end
20
+ class NoTransactionInControllers < RuboCop::Cop::Base
21
+ MSG = 'Database transactions are not allowed in controllers. Move transactional ' \
22
+ 'logic into a GLCommand or service object.'.freeze
23
+
24
+ # Matches `.transaction` called on a constant receiver, e.g.
25
+ # ActiveRecord::Base.transaction, ApplicationRecord.transaction, SomeModel.transaction
26
+ def_node_matcher :transaction_on_const?, <<~PATTERN
27
+ (send (const ...) :transaction ...)
28
+ PATTERN
29
+
30
+ def on_send(node)
31
+ return unless transaction_on_const?(node)
32
+
33
+ add_offense(node)
34
+ end
35
+ end
36
+ end
37
+ end
@@ -1,3 +1,3 @@
1
1
  module GLRubocop
2
- VERSION = '0.5.4'.freeze
2
+ VERSION = '0.5.5'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gl_rubocop
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.4
4
+ version: 0.5.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Give Lively
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2026-06-22 00:00:00.000000000 Z
11
+ date: 2026-08-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubocop
@@ -170,6 +170,7 @@ files:
170
170
  - lib/gl_rubocop/gl_cops/no_hardcoded_strings_in_erb_text_elements.rb
171
171
  - lib/gl_rubocop/gl_cops/no_stubbing_env.rb
172
172
  - lib/gl_rubocop/gl_cops/no_stubbing_perform_async.rb
173
+ - lib/gl_rubocop/gl_cops/no_transaction_in_controllers.rb
173
174
  - lib/gl_rubocop/gl_cops/prevent_haml_files.rb
174
175
  - lib/gl_rubocop/gl_cops/rails_cache.rb
175
176
  - lib/gl_rubocop/gl_cops/sidekiq_inherits_from_sidekiq_job.rb
@@ -205,7 +206,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
205
206
  - !ruby/object:Gem::Version
206
207
  version: '0'
207
208
  requirements: []
208
- rubygems_version: 3.5.22
209
+ rubygems_version: 3.3.27
209
210
  signing_key:
210
211
  specification_version: 4
211
212
  summary: A shareable configuration of Give Lively's rubocop rules.