carwow_rubocop 4.1.1 → 5.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: 1593ae97f23dd4375b5bea2eee710c9767e912d50e3afa4a6bbf270f2f72bcb9
4
- data.tar.gz: d29273a7037782e92b8e88aa8922e1993195b5a47616d1a40d15dce5560caae9
3
+ metadata.gz: e23461bfdf3292ee603d6094aaa3b6b5d6e0e9d5475e3db9bf7345674b57076d
4
+ data.tar.gz: ced30bc35295b82176b390599e33f9bb6b54a150be76c3c5e04bd2329a775855
5
5
  SHA512:
6
- metadata.gz: af53a7e90bb870699a174da4b1ca943755e93be8bd867d38ee967a1f1b68a8538aec28fcee0e522397f6fc0c43bee7c415b1a43187ea211a5c0c3fefa35bb9ad
7
- data.tar.gz: '0490e795a93c139d24694994778ee63875698cf694b2bba8d63d3697b21b2b65dd729bdc7fa6acdb92a9d6d2d34e74435a1e8b3e126bff281ad9d322a12d1a2a'
6
+ metadata.gz: 9faf779b59d6ba0bf8cd5c5076869eb29b90874f0d845e3a95ba058d55bca36811476962c94b76ece7bd4f89a4b45517414d05a9021fe84f3297e2e9ad8f0892
7
+ data.tar.gz: b7dc05cf6539f33a19f17aa572f29985963c757288592782ffeb0298d4b400b4831af5ccbaec183856dec7cc9ac105802cd0e86b23ec46695a823bdf7bc1b67c
data/.circleci/config.yml CHANGED
@@ -32,7 +32,7 @@ jobs:
32
32
  steps:
33
33
  - checkout
34
34
  - run: bundle install --jobs=4 --retry=3
35
- - run: bundle exec rubocop -p
35
+ - run: bundle exec rubocop --parallel
36
36
 
37
37
 
38
38
 
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- carwow_rubocop (4.1.1)
4
+ carwow_rubocop (5.0.0)
5
5
  rubocop (>= 1.44)
6
6
  rubocop-performance
7
7
  rubocop-rspec
@@ -15,14 +15,14 @@ GEM
15
15
  json (2.6.3)
16
16
  method_source (1.0.0)
17
17
  parallel (1.22.1)
18
- parser (3.2.0.0)
18
+ parser (3.2.2.0)
19
19
  ast (~> 2.4.1)
20
20
  pry (0.14.2)
21
21
  coderay (~> 1.1)
22
22
  method_source (~> 1.0)
23
23
  rainbow (3.1.1)
24
24
  rake (13.0.6)
25
- regexp_parser (2.6.2)
25
+ regexp_parser (2.7.0)
26
26
  rexml (3.2.5)
27
27
  rspec (3.12.0)
28
28
  rspec-core (~> 3.12.0)
@@ -37,27 +37,27 @@ GEM
37
37
  diff-lcs (>= 1.2.0, < 2.0)
38
38
  rspec-support (~> 3.12.0)
39
39
  rspec-support (3.12.0)
40
- rubocop (1.44.1)
40
+ rubocop (1.50.1)
41
41
  json (~> 2.3)
42
42
  parallel (~> 1.10)
43
43
  parser (>= 3.2.0.0)
44
44
  rainbow (>= 2.2.2, < 4.0)
45
45
  regexp_parser (>= 1.8, < 3.0)
46
46
  rexml (>= 3.2.5, < 4.0)
47
- rubocop-ast (>= 1.24.1, < 2.0)
47
+ rubocop-ast (>= 1.28.0, < 2.0)
48
48
  ruby-progressbar (~> 1.7)
49
49
  unicode-display_width (>= 2.4.0, < 3.0)
50
- rubocop-ast (1.24.1)
51
- parser (>= 3.1.1.0)
52
- rubocop-capybara (2.17.0)
50
+ rubocop-ast (1.28.0)
51
+ parser (>= 3.2.1.0)
52
+ rubocop-capybara (2.17.1)
53
53
  rubocop (~> 1.41)
54
- rubocop-performance (1.15.2)
54
+ rubocop-performance (1.17.1)
55
55
  rubocop (>= 1.7.0, < 2.0)
56
56
  rubocop-ast (>= 0.4.0)
57
- rubocop-rspec (2.18.1)
57
+ rubocop-rspec (2.19.0)
58
58
  rubocop (~> 1.33)
59
59
  rubocop-capybara (~> 2.17)
60
- ruby-progressbar (1.11.0)
60
+ ruby-progressbar (1.13.0)
61
61
  unicode-display_width (2.4.2)
62
62
 
63
63
  PLATFORMS
data/config/default.yml CHANGED
@@ -7,7 +7,7 @@ require:
7
7
  # Global rules
8
8
 
9
9
  AllCops:
10
- TargetRubyVersion: 2.7
10
+ TargetRubyVersion: 3.1
11
11
  NewCops: enable
12
12
  Exclude:
13
13
  - '.git/**/*'
@@ -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"
@@ -1,5 +1,5 @@
1
1
  module RuboCop
2
2
  module Carwow
3
- VERSION = '4.1.1'.freeze
3
+ VERSION = '5.0.0'.freeze
4
4
  end
5
5
  end
@@ -1,7 +1,7 @@
1
1
  require 'pathname'
2
2
  require 'psych'
3
3
 
4
- Dir.glob(File.expand_path('cop/**/*.rb', File.dirname(__FILE__))).sort.each do |file|
4
+ Dir.glob(File.expand_path('cop/**/*.rb', File.dirname(__FILE__))).each do |file|
5
5
  require file
6
6
  end
7
7
 
@@ -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.1.1
4
+ version: 5.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-01-25 00:00:00.000000000 Z
11
+ date: 2023-08-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -144,6 +144,7 @@ files:
144
144
  - lib/rubocop/carwow.rb
145
145
  - lib/rubocop/carwow/inject.rb
146
146
  - lib/rubocop/carwow/version.rb
147
+ - lib/rubocop/cop/carwow/add_column_with_comment.rb
147
148
  - lib/rubocop/cop/carwow/jobs.rb
148
149
  - lib/rubocop/cop/carwow/jobs_must_define_queue.rb
149
150
  - lib/rubocop/cop/carwow/jobs_queue_name_style.rb
@@ -153,7 +154,7 @@ licenses:
153
154
  - MIT
154
155
  metadata:
155
156
  rubygems_mfa_required: 'true'
156
- post_install_message:
157
+ post_install_message:
157
158
  rdoc_options: []
158
159
  require_paths:
159
160
  - lib
@@ -169,7 +170,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
169
170
  version: '0'
170
171
  requirements: []
171
172
  rubygems_version: 3.1.6
172
- signing_key:
173
+ signing_key:
173
174
  specification_version: 4
174
175
  summary: carwow's rubocop configuration
175
176
  test_files: []