rubocop-config-captive 1.12.0 → 1.16.1
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f99323665b07ddee16ef287c37c3d3d0e8e69976e81534b10880bf7b6a4a0e6c
|
4
|
+
data.tar.gz: 1e0355369871f031e909e215203e82b25454ba3f9b81f10fe97232c74dcdeae4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6b070046a311cb2e15df47754629a427020cf3f3b88f7fe8d486ceb4af79083988ed8134efcd5bd11451201b6beb1d5078f5e89c973b8f4b133b7b338ea35999
|
7
|
+
data.tar.gz: 964cf6b224d95f54b23c7dbfb4767734945f6621d935c69e4d5e51e03ba069d530ab38f9dce2f2869e7894aca1cb07416d653e906fd83c0c4f9b4550eeeb7fb7
|
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,30 @@
|
|
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
|
+
#
|
9
|
+
# @see https://stackoverflow.com/questions/31329554/find-by-inside-a-scope-is-firing-2-queries
|
10
|
+
class NoFindByInScope < RuboCop::Cop::Cop
|
11
|
+
MSG = "Avoid using `find_by` in a scope. Use `where` to return \
|
12
|
+
a collection or define a class method if you need a single record."
|
13
|
+
|
14
|
+
def_node_matcher :find_by_in_scope?, <<~PATTERN
|
15
|
+
(block
|
16
|
+
(send nil? :scope ...)
|
17
|
+
(args ...)
|
18
|
+
(send nil? :find_by ...))
|
19
|
+
PATTERN
|
20
|
+
|
21
|
+
def on_block(node)
|
22
|
+
find_by_in_scope?(node) do
|
23
|
+
add_offense(node, message: MSG)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -25,14 +25,14 @@ Gem::Specification.new do |gem|
|
|
25
25
|
# ⚠️ Instead of depending on rubocop-airbnb we copy sources
|
26
26
|
#
|
27
27
|
# gem.add_dependency('rubocop-airbnb', '~> 4.0.0')
|
28
|
-
gem.add_dependency("rubocop", "~> 1.
|
29
|
-
gem.add_dependency("rubocop-performance", "~> 1.
|
28
|
+
gem.add_dependency("rubocop", "~> 1.69.2")
|
29
|
+
gem.add_dependency("rubocop-performance", "~> 1.23.0 ")
|
30
30
|
gem.add_dependency("rubocop-rake", "~> 0.6.0")
|
31
|
-
gem.add_dependency("rubocop-rails", "~> 2.
|
32
|
-
gem.add_dependency("rubocop-rspec", "~>
|
33
|
-
gem.add_dependency("rubocop-capybara", "~> 2.
|
34
|
-
gem.add_dependency("rubocop-factory_bot", "~> 2.
|
35
|
-
gem.add_dependency("rubocop-magic_numbers", "~> 0.
|
31
|
+
gem.add_dependency("rubocop-rails", "~> 2.27.0")
|
32
|
+
gem.add_dependency("rubocop-rspec", "~> 3.3.0")
|
33
|
+
gem.add_dependency("rubocop-capybara", "~> 2.21.0")
|
34
|
+
gem.add_dependency("rubocop-factory_bot", "~> 2.26.1")
|
35
|
+
gem.add_dependency("rubocop-magic_numbers", "~> 0.5.0")
|
36
36
|
gem.add_development_dependency("rspec", "~> 3.12")
|
37
37
|
# gem.metadata['rubygems_mfa_required'] = 'true'
|
38
38
|
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.16.1
|
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-12-14 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rubocop
|
@@ -18,28 +18,28 @@ dependencies:
|
|
18
18
|
requirements:
|
19
19
|
- - "~>"
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: 1.
|
21
|
+
version: 1.69.2
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
25
|
requirements:
|
26
26
|
- - "~>"
|
27
27
|
- !ruby/object:Gem::Version
|
28
|
-
version: 1.
|
28
|
+
version: 1.69.2
|
29
29
|
- !ruby/object:Gem::Dependency
|
30
30
|
name: rubocop-performance
|
31
31
|
requirement: !ruby/object:Gem::Requirement
|
32
32
|
requirements:
|
33
33
|
- - "~>"
|
34
34
|
- !ruby/object:Gem::Version
|
35
|
-
version: 1.
|
35
|
+
version: 1.23.0
|
36
36
|
type: :runtime
|
37
37
|
prerelease: false
|
38
38
|
version_requirements: !ruby/object:Gem::Requirement
|
39
39
|
requirements:
|
40
40
|
- - "~>"
|
41
41
|
- !ruby/object:Gem::Version
|
42
|
-
version: 1.
|
42
|
+
version: 1.23.0
|
43
43
|
- !ruby/object:Gem::Dependency
|
44
44
|
name: rubocop-rake
|
45
45
|
requirement: !ruby/object:Gem::Requirement
|
@@ -60,70 +60,70 @@ dependencies:
|
|
60
60
|
requirements:
|
61
61
|
- - "~>"
|
62
62
|
- !ruby/object:Gem::Version
|
63
|
-
version: 2.
|
63
|
+
version: 2.27.0
|
64
64
|
type: :runtime
|
65
65
|
prerelease: false
|
66
66
|
version_requirements: !ruby/object:Gem::Requirement
|
67
67
|
requirements:
|
68
68
|
- - "~>"
|
69
69
|
- !ruby/object:Gem::Version
|
70
|
-
version: 2.
|
70
|
+
version: 2.27.0
|
71
71
|
- !ruby/object:Gem::Dependency
|
72
72
|
name: rubocop-rspec
|
73
73
|
requirement: !ruby/object:Gem::Requirement
|
74
74
|
requirements:
|
75
75
|
- - "~>"
|
76
76
|
- !ruby/object:Gem::Version
|
77
|
-
version:
|
77
|
+
version: 3.3.0
|
78
78
|
type: :runtime
|
79
79
|
prerelease: false
|
80
80
|
version_requirements: !ruby/object:Gem::Requirement
|
81
81
|
requirements:
|
82
82
|
- - "~>"
|
83
83
|
- !ruby/object:Gem::Version
|
84
|
-
version:
|
84
|
+
version: 3.3.0
|
85
85
|
- !ruby/object:Gem::Dependency
|
86
86
|
name: rubocop-capybara
|
87
87
|
requirement: !ruby/object:Gem::Requirement
|
88
88
|
requirements:
|
89
89
|
- - "~>"
|
90
90
|
- !ruby/object:Gem::Version
|
91
|
-
version: 2.
|
91
|
+
version: 2.21.0
|
92
92
|
type: :runtime
|
93
93
|
prerelease: false
|
94
94
|
version_requirements: !ruby/object:Gem::Requirement
|
95
95
|
requirements:
|
96
96
|
- - "~>"
|
97
97
|
- !ruby/object:Gem::Version
|
98
|
-
version: 2.
|
98
|
+
version: 2.21.0
|
99
99
|
- !ruby/object:Gem::Dependency
|
100
100
|
name: rubocop-factory_bot
|
101
101
|
requirement: !ruby/object:Gem::Requirement
|
102
102
|
requirements:
|
103
103
|
- - "~>"
|
104
104
|
- !ruby/object:Gem::Version
|
105
|
-
version: 2.
|
105
|
+
version: 2.26.1
|
106
106
|
type: :runtime
|
107
107
|
prerelease: false
|
108
108
|
version_requirements: !ruby/object:Gem::Requirement
|
109
109
|
requirements:
|
110
110
|
- - "~>"
|
111
111
|
- !ruby/object:Gem::Version
|
112
|
-
version: 2.
|
112
|
+
version: 2.26.1
|
113
113
|
- !ruby/object:Gem::Dependency
|
114
114
|
name: rubocop-magic_numbers
|
115
115
|
requirement: !ruby/object:Gem::Requirement
|
116
116
|
requirements:
|
117
117
|
- - "~>"
|
118
118
|
- !ruby/object:Gem::Version
|
119
|
-
version: 0.
|
119
|
+
version: 0.5.0
|
120
120
|
type: :runtime
|
121
121
|
prerelease: false
|
122
122
|
version_requirements: !ruby/object:Gem::Requirement
|
123
123
|
requirements:
|
124
124
|
- - "~>"
|
125
125
|
- !ruby/object:Gem::Version
|
126
|
-
version: 0.
|
126
|
+
version: 0.5.0
|
127
127
|
- !ruby/object:Gem::Dependency
|
128
128
|
name: rspec
|
129
129
|
requirement: !ruby/object:Gem::Requirement
|
@@ -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
|