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 +4 -4
- data/.circleci/config.yml +1 -1
- data/Gemfile.lock +11 -11
- data/config/default.yml +1 -1
- data/config/rubocop-carwow.yml +5 -0
- data/lib/rubocop/carwow/version.rb +1 -1
- data/lib/rubocop/carwow.rb +1 -1
- data/lib/rubocop/cop/carwow/add_column_with_comment.rb +65 -0
- metadata +6 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e23461bfdf3292ee603d6094aaa3b6b5d6e0e9d5475e3db9bf7345674b57076d
|
4
|
+
data.tar.gz: ced30bc35295b82176b390599e33f9bb6b54a150be76c3c5e04bd2329a775855
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9faf779b59d6ba0bf8cd5c5076869eb29b90874f0d845e3a95ba058d55bca36811476962c94b76ece7bd4f89a4b45517414d05a9021fe84f3297e2e9ad8f0892
|
7
|
+
data.tar.gz: b7dc05cf6539f33a19f17aa572f29985963c757288592782ffeb0298d4b400b4831af5ccbaec183856dec7cc9ac105802cd0e86b23ec46695a823bdf7bc1b67c
|
data/.circleci/config.yml
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
carwow_rubocop (
|
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.
|
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.
|
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.
|
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.
|
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.
|
51
|
-
parser (>= 3.
|
52
|
-
rubocop-capybara (2.17.
|
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.
|
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.
|
57
|
+
rubocop-rspec (2.19.0)
|
58
58
|
rubocop (~> 1.33)
|
59
59
|
rubocop-capybara (~> 2.17)
|
60
|
-
ruby-progressbar (1.
|
60
|
+
ruby-progressbar (1.13.0)
|
61
61
|
unicode-display_width (2.4.2)
|
62
62
|
|
63
63
|
PLATFORMS
|
data/config/default.yml
CHANGED
data/config/rubocop-carwow.yml
CHANGED
data/lib/rubocop/carwow.rb
CHANGED
@@ -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
|
+
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-
|
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: []
|