rubocop-schema 0.2.7 → 0.2.9
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/lib/rubocop/cop/style/migration_comments.rb +25 -5
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ece77be455b49c3461da9bbc53fca869111a7fa8
|
4
|
+
data.tar.gz: 79179b67fe3ac8f48d8f2e304acc51934fd76b17
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bdd79b4f11bbdc4e24e3820374753a0f3a8732a1c56bddf7082c245f7e9c820c1db22633a1503ac5d09349c72362b772280b5bf36cf48e250064a505dcee9d4c
|
7
|
+
data.tar.gz: 3be3311ec84168889c59ef467856eea4d53287f4048a739c86576befd0dcc0bf80d007028298f52a0ec70417e68f89b6190973affe49489ee5531ae43a29ac7b
|
@@ -10,11 +10,11 @@ module RuboCop
|
|
10
10
|
COMMON_DB_FIELDS = %w(:deleted_at :id :creator_id :deleter_id :created_at :updated_at).freeze
|
11
11
|
|
12
12
|
def on_def(node)
|
13
|
-
|
14
|
-
if body.type == :send
|
15
|
-
process_block_child_node(body)
|
13
|
+
|
14
|
+
if node.body.type == :send
|
15
|
+
process_block_child_node(node.body)
|
16
16
|
else
|
17
|
-
body.each_child_node do |ancestor|
|
17
|
+
node.body.each_child_node do |ancestor|
|
18
18
|
process_block_child_node(ancestor)
|
19
19
|
end
|
20
20
|
end
|
@@ -23,7 +23,27 @@ module RuboCop
|
|
23
23
|
private
|
24
24
|
|
25
25
|
def process_block_child_node(ancestor)
|
26
|
-
|
26
|
+
if ancestor.type == :block
|
27
|
+
return unless ancestor.send_node.source.start_with? "create_table"
|
28
|
+
ancestor.body.each_child_node do |innder_ancestor|
|
29
|
+
process_entries_inside_create_table(innder_ancestor)
|
30
|
+
end
|
31
|
+
else
|
32
|
+
first_child = ancestor.children[1]
|
33
|
+
return unless first_child == :add_column
|
34
|
+
|
35
|
+
field_name = ancestor.children[3].source
|
36
|
+
return if COMMON_DB_FIELDS.include? field_name
|
37
|
+
|
38
|
+
last_child = ancestor.children[-1]
|
39
|
+
return if last_child.type == :hash && last_child.each_key.any? {|key| [":comment", "comment"].include? key.source}
|
40
|
+
|
41
|
+
add_offense(ancestor, :expression)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def process_entries_inside_create_table(ancestor)
|
46
|
+
field_name = ancestor.children[2].source
|
27
47
|
return if COMMON_DB_FIELDS.include? field_name
|
28
48
|
|
29
49
|
last_child = ancestor.children[-1]
|