carwow_rubocop 4.2.0 → 5.0.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 +4 -4
- data/Gemfile.lock +1 -1
- data/config/rubocop-carwow.yml +5 -0
- data/lib/rubocop/carwow/version.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/Gemfile.lock
CHANGED
data/config/rubocop-carwow.yml
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: []
|