rubocop-config-captive 1.12.0 → 1.13.0
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b503af1733f071e5c225a59a847816f26d0875946d448922b6cc3b2a2ae6d9f2
|
4
|
+
data.tar.gz: e20df47f5ee50dc31edebc772837db84d83041bc6c825fa10e1cbf5c3c0f30d8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 462270c228e9abb16e6a204bcbd35f46051e71343688333b968ac2e3b347ed344c160d150ba4f58a0adcb56527db72067ae96810964164321c1d2f474aaaa1a6
|
7
|
+
data.tar.gz: 4aa2cad847ffb5f47859cd15288693cfa0bfb5fbd20eb2adc56689e181e65099aa393b181367c5ceb9d8813405739842c2c3e5e517a442b804f570fd12c3a490
|
data/config/rubocop-captive.yml
CHANGED
@@ -8,6 +8,7 @@ require:
|
|
8
8
|
- ../lib/rubocop/cop/captive/rails/migration_methods.rb
|
9
9
|
- ../lib/rubocop/cop/captive/rails/no_email_from_controller.rb
|
10
10
|
- ../lib/rubocop/cop/captive/rails/no_float_price_columns.rb
|
11
|
+
- ../lib/rubocop/cop/captive/rails/no_find_by_in_scope.rb
|
11
12
|
- ../lib/rubocop/cop/captive/string_where_in_scope.rb
|
12
13
|
- ../lib/rubocop/cop/captive/no_app_env.rb
|
13
14
|
|
@@ -39,30 +40,31 @@ Captive/RSpec/SpecifyBeforeParameter:
|
|
39
40
|
Include:
|
40
41
|
- 'spec/**/*'
|
41
42
|
|
42
|
-
# Rails
|
43
43
|
Captive/Rails/ForceSslEnabledInProduction:
|
44
44
|
Description: "Ensures SSL is forced in production, so that secure cookies are used."
|
45
45
|
Include:
|
46
46
|
- 'config/environments/production.rb'
|
47
47
|
|
48
|
-
# Rails
|
49
48
|
Captive/Rails/MigrationMethods:
|
50
49
|
Description: "Avoid using ActiveRecord::Migration methods in `up` and `down` methods. Use `change` instead."
|
51
50
|
Include:
|
52
51
|
- 'db/migrate/**/*'
|
53
52
|
|
54
|
-
# Rails
|
55
53
|
Captive/Rails/NoEmailFromController:
|
56
54
|
Description: "Do not send emails from controllers. Because it doesn't follow the MVC standard"
|
57
55
|
Include:
|
58
56
|
- 'app/controllers/**/*'
|
59
57
|
|
60
|
-
# Rails
|
61
58
|
Captive/Rails/NoFloatPriceColumns:
|
62
59
|
Description: "Avoid using `float` type for price columns. Use `decimal, precision: 10, scale: 2` instead."
|
63
60
|
Include:
|
64
61
|
- 'db/migrate/**/*'
|
65
62
|
|
63
|
+
Captive/Rails/NoFindByInScope:
|
64
|
+
Description: "Avoid using `find_by` in a scope. Use `where` to return a collection or define a class method if you need a single record."
|
65
|
+
Include:
|
66
|
+
- 'app/models/**/*'
|
67
|
+
|
66
68
|
# other
|
67
69
|
Captive/StringWhereInScope:
|
68
70
|
Description: 'The `where` method should be used in a scope in a model.'
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RuboCop
|
4
|
+
module Cop
|
5
|
+
module Captive
|
6
|
+
module Rails
|
7
|
+
# Avoid using `find_by` in a scope. Use `where` to return a collection or define a class method if you need a single record.
|
8
|
+
class NoFindByInScope < RuboCop::Cop::Cop
|
9
|
+
MSG = "Avoid using `find_by` in a scope. Use `where` to return \
|
10
|
+
a collection or define a class method if you need a single record."
|
11
|
+
|
12
|
+
def_node_matcher :find_by_in_scope?, <<~PATTERN
|
13
|
+
(block
|
14
|
+
(send nil? :scope ...)
|
15
|
+
(args ...)
|
16
|
+
(send nil? :find_by ...))
|
17
|
+
PATTERN
|
18
|
+
|
19
|
+
def on_block(node)
|
20
|
+
find_by_in_scope?(node) do
|
21
|
+
add_offense(node, message: MSG)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubocop-config-captive
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.13.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Captive
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2024-
|
13
|
+
date: 2024-09-25 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rubocop
|
@@ -187,6 +187,7 @@ files:
|
|
187
187
|
- lib/rubocop/cop/captive/rails/force_ssl_enabled_in_production.rb
|
188
188
|
- lib/rubocop/cop/captive/rails/migration_methods.rb
|
189
189
|
- lib/rubocop/cop/captive/rails/no_email_from_controller.rb
|
190
|
+
- lib/rubocop/cop/captive/rails/no_find_by_in_scope.rb
|
190
191
|
- lib/rubocop/cop/captive/rails/no_float_price_columns.rb
|
191
192
|
- lib/rubocop/cop/captive/rspec/specify_before_parameter.rb
|
192
193
|
- lib/rubocop/cop/captive/string_where_in_scope.rb
|