carwow_rubocop 4.2.0 → 6.0.0

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: fb0368d67c7728b8bb6ae4427868535d8e1fca18fc91eaf7cf61409a74116827
4
- data.tar.gz: e0a7aee5cc8953d93e1aa5e5e85bc538b3c237f3306c4eb0e595df841066fe39
3
+ metadata.gz: 2502f69ed5e5cd4255c0b1bf1c5c693aaf99d59a8b098ab35eef2dcd3d7b7eff
4
+ data.tar.gz: 2c5e6df20f64962209d92ee0fd8c709cfdc4ea90f09406ca84473bbe53bbb19e
5
5
  SHA512:
6
- metadata.gz: d681a96c87057770250378b262ca70963d4d20c5987daca64d26c45a8dac9de816775d911d57e0df522d7c08c381f8e9f6ee80e849c976e075b89ad8d737744b
7
- data.tar.gz: 4fae7c1ba3b2a704af6248f7a9e7e970cfcc75498ab6f0db637359f95afda913a6d663abbe44f68d658b7d1090a657111a6cd0d976a07673f46094c8ebba771e
6
+ metadata.gz: 91474e6f5948d8a99c2f82d6835dd680308bbcda86273639b78a54f750af43fc6dd8763a7b10c33467426f3dbece2a3170f610a1a02915d01ca4599b12fff828
7
+ data.tar.gz: bab97908a5aec300ca75d9ea208e0b99fb70da355958fa50b7f5f69882cc16de63c89c602509577dac7b0337acbc4e9c734e8fd268bc56b83681bd7f87aa6537
data/Gemfile.lock CHANGED
@@ -1,8 +1,9 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- carwow_rubocop (4.2.0)
4
+ carwow_rubocop (6.0.0)
5
5
  rubocop (>= 1.44)
6
+ rubocop-factory_bot
6
7
  rubocop-performance
7
8
  rubocop-rspec
8
9
 
@@ -11,54 +12,55 @@ GEM
11
12
  specs:
12
13
  ast (2.4.2)
13
14
  coderay (1.1.3)
14
- diff-lcs (1.5.0)
15
- json (2.6.3)
15
+ diff-lcs (1.5.1)
16
+ json (2.7.2)
17
+ language_server-protocol (3.17.0.3)
16
18
  method_source (1.0.0)
17
- parallel (1.22.1)
18
- parser (3.2.2.0)
19
+ parallel (1.26.3)
20
+ parser (3.3.5.0)
19
21
  ast (~> 2.4.1)
22
+ racc
20
23
  pry (0.14.2)
21
24
  coderay (~> 1.1)
22
25
  method_source (~> 1.0)
26
+ racc (1.8.1)
23
27
  rainbow (3.1.1)
24
- rake (13.0.6)
25
- regexp_parser (2.7.0)
26
- rexml (3.2.5)
27
- rspec (3.12.0)
28
- rspec-core (~> 3.12.0)
29
- rspec-expectations (~> 3.12.0)
30
- rspec-mocks (~> 3.12.0)
31
- rspec-core (3.12.0)
32
- rspec-support (~> 3.12.0)
33
- rspec-expectations (3.12.2)
28
+ rake (13.2.1)
29
+ regexp_parser (2.9.2)
30
+ rspec (3.13.0)
31
+ rspec-core (~> 3.13.0)
32
+ rspec-expectations (~> 3.13.0)
33
+ rspec-mocks (~> 3.13.0)
34
+ rspec-core (3.13.0)
35
+ rspec-support (~> 3.13.0)
36
+ rspec-expectations (3.13.0)
34
37
  diff-lcs (>= 1.2.0, < 2.0)
35
- rspec-support (~> 3.12.0)
36
- rspec-mocks (3.12.3)
38
+ rspec-support (~> 3.13.0)
39
+ rspec-mocks (3.13.1)
37
40
  diff-lcs (>= 1.2.0, < 2.0)
38
- rspec-support (~> 3.12.0)
39
- rspec-support (3.12.0)
40
- rubocop (1.50.1)
41
+ rspec-support (~> 3.13.0)
42
+ rspec-support (3.13.1)
43
+ rubocop (1.66.1)
41
44
  json (~> 2.3)
45
+ language_server-protocol (>= 3.17.0)
42
46
  parallel (~> 1.10)
43
- parser (>= 3.2.0.0)
47
+ parser (>= 3.3.0.2)
44
48
  rainbow (>= 2.2.2, < 4.0)
45
- regexp_parser (>= 1.8, < 3.0)
46
- rexml (>= 3.2.5, < 4.0)
47
- rubocop-ast (>= 1.28.0, < 2.0)
49
+ regexp_parser (>= 2.4, < 3.0)
50
+ rubocop-ast (>= 1.32.2, < 2.0)
48
51
  ruby-progressbar (~> 1.7)
49
52
  unicode-display_width (>= 2.4.0, < 3.0)
50
- rubocop-ast (1.28.0)
51
- parser (>= 3.2.1.0)
52
- rubocop-capybara (2.17.1)
53
- rubocop (~> 1.41)
54
- rubocop-performance (1.17.1)
55
- rubocop (>= 1.7.0, < 2.0)
56
- rubocop-ast (>= 0.4.0)
57
- rubocop-rspec (2.19.0)
58
- rubocop (~> 1.33)
59
- rubocop-capybara (~> 2.17)
53
+ rubocop-ast (1.32.3)
54
+ parser (>= 3.3.1.0)
55
+ rubocop-factory_bot (2.26.1)
56
+ rubocop (~> 1.61)
57
+ rubocop-performance (1.22.1)
58
+ rubocop (>= 1.48.1, < 2.0)
59
+ rubocop-ast (>= 1.31.1, < 2.0)
60
+ rubocop-rspec (3.0.5)
61
+ rubocop (~> 1.61)
60
62
  ruby-progressbar (1.13.0)
61
- unicode-display_width (2.4.2)
63
+ unicode-display_width (2.6.0)
62
64
 
63
65
  PLATFORMS
64
66
  ruby
@@ -36,7 +36,7 @@ Gem::Specification.new do |spec|
36
36
  spec.add_dependency 'rubocop', '>= 1.44'
37
37
  spec.add_dependency 'rubocop-performance'
38
38
  spec.add_dependency 'rubocop-rspec'
39
+ spec.add_dependency 'rubocop-factory_bot'
39
40
  spec.metadata = {
40
- 'rubygems_mfa_required' => 'true'
41
41
  }
42
42
  end
data/config/default.yml CHANGED
@@ -32,3 +32,4 @@ inherit_from:
32
32
  - './rubocop-rspec.yml'
33
33
  - './rubocop-security.yml'
34
34
  - './rubocop-style.yml'
35
+ - './rubocop-factory_bot.yml'
@@ -31,3 +31,8 @@ Carwow/NoStubbingBusinessEvent:
31
31
  Include: &spec_only
32
32
  - "**/*_spec.rb"
33
33
  - "**/spec/**/*"
34
+
35
+ Carwow/AddColumnWithComment:
36
+ Enabled: true
37
+ Include: &migrations_only
38
+ - "**/db/migrate/**/*.rb"
@@ -0,0 +1,8 @@
1
+ require:
2
+ - rubocop-factory_bot
3
+
4
+ FactoryBot:
5
+ Include:
6
+ - spec/factories/**/*.rb
7
+ - features/support/factories/**/*.rb
8
+
@@ -5,10 +5,6 @@ RSpec:
5
5
  Include:
6
6
  - _spec.rb
7
7
  - "(?:^|/)spec/"
8
- RSpec/FactoryBot:
9
- Include:
10
- - spec/factories/**/*.rb
11
- - features/support/factories/**/*.rb
12
8
 
13
9
  RSpec/ContextWording:
14
10
  Enabled: False
@@ -1,5 +1,5 @@
1
1
  module RuboCop
2
2
  module Carwow
3
- VERSION = '4.2.0'.freeze
3
+ VERSION = '6.0.0'.freeze
4
4
  end
5
5
  end
@@ -0,0 +1,65 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'rubocop'
4
+
5
+ module RuboCop
6
+ module Cop
7
+ module Carwow
8
+ # Checks the migration to confirm that new columns have a comment.
9
+ #
10
+ # @example
11
+ # # bad
12
+ # add_column :users, :name, :string
13
+ #
14
+ # # bad
15
+ # create_table :users do |t|
16
+ # t.string :name
17
+ # t.string :email
18
+ # end
19
+ #
20
+ # # good
21
+ # add_column :users, :name, :string, comment: 'The name of the user'
22
+ #
23
+ # # good
24
+ # create_table :users do |t|
25
+ # t.string :name, comment: 'The name of the user'
26
+ # t.string :email, comment: 'The email of the user'
27
+ # end
28
+ #
29
+ class AddColumnWithComment < Cop
30
+ MSG = "Missing 'comment' parameter for new column."
31
+
32
+ def_node_matcher :inside_create_table_block?, <<~PATTERN
33
+ (block (send nil? :create_table ...) (args ...) ...)
34
+ PATTERN
35
+
36
+ def_node_matcher :add_column?, <<~PATTERN
37
+ (send nil? :add_column ...)
38
+ PATTERN
39
+
40
+ def on_send(node)
41
+ return unless add_column?(node) || inside_create_table_block?(node.parent.parent)
42
+
43
+ # Timestamps and indexes do not need comments
44
+ return if %i[timestamps index].include?(node.method_name)
45
+
46
+ # Extract arguments
47
+ _receiver, _method_name, *args = *node
48
+
49
+ # Check if there is a 'comment' argument
50
+ comment_arg = find_comment_arg(args)
51
+
52
+ return if comment_arg
53
+
54
+ add_offense(node, location: :expression, message: MSG)
55
+ end
56
+
57
+ private
58
+
59
+ def find_comment_arg(args)
60
+ args.find { |arg| arg.hash_type? && arg.pairs.any? { |pair| pair.key.value == :comment } }
61
+ end
62
+ end
63
+ end
64
+ end
65
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: carwow_rubocop
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.2.0
4
+ version: 6.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - carwow Developers
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-04-14 00:00:00.000000000 Z
11
+ date: 2024-09-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -108,6 +108,20 @@ dependencies:
108
108
  - - ">="
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: rubocop-factory_bot
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
111
125
  description: All carwow's ruby projects will follow these rules
112
126
  email:
113
127
  - developers@carwow.co.uk
@@ -130,6 +144,7 @@ files:
130
144
  - config/default.yml
131
145
  - config/rubocop-bundler.yml
132
146
  - config/rubocop-carwow.yml
147
+ - config/rubocop-factory_bot.yml
133
148
  - config/rubocop-gemspec.yml
134
149
  - config/rubocop-layout.yml
135
150
  - config/rubocop-lint.yml
@@ -144,6 +159,7 @@ files:
144
159
  - lib/rubocop/carwow.rb
145
160
  - lib/rubocop/carwow/inject.rb
146
161
  - lib/rubocop/carwow/version.rb
162
+ - lib/rubocop/cop/carwow/add_column_with_comment.rb
147
163
  - lib/rubocop/cop/carwow/jobs.rb
148
164
  - lib/rubocop/cop/carwow/jobs_must_define_queue.rb
149
165
  - lib/rubocop/cop/carwow/jobs_queue_name_style.rb
@@ -151,9 +167,8 @@ files:
151
167
  homepage: https://github.com/carwow/carwow_rubocop
152
168
  licenses:
153
169
  - MIT
154
- metadata:
155
- rubygems_mfa_required: 'true'
156
- post_install_message:
170
+ metadata: {}
171
+ post_install_message:
157
172
  rdoc_options: []
158
173
  require_paths:
159
174
  - lib
@@ -168,8 +183,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
168
183
  - !ruby/object:Gem::Version
169
184
  version: '0'
170
185
  requirements: []
171
- rubygems_version: 3.1.6
172
- signing_key:
186
+ rubygems_version: 3.5.20
187
+ signing_key:
173
188
  specification_version: 4
174
189
  summary: carwow's rubocop configuration
175
190
  test_files: []