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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 32935e4c25c7ff0b5e503227dfac62de32ceef8a
4
- data.tar.gz: af233508c74921aaac137e05dd3dd7d72eee9934
3
+ metadata.gz: ece77be455b49c3461da9bbc53fca869111a7fa8
4
+ data.tar.gz: 79179b67fe3ac8f48d8f2e304acc51934fd76b17
5
5
  SHA512:
6
- metadata.gz: 5ca7e8f31670278f2cfdad82ca4b94edb375b168750ffbb02a817d28925308ad4d5ce763c1e7e4bc2f1781778a7e4a2586af7404aa353379f815a521d2c26f33
7
- data.tar.gz: 563d994ed24b1727abdbdaf2f2e4d975fb0a9f2a5ed84a5b81d417118ac48fa83947da878d4e43c39c243c4421e7dbb0cc032e948f6e244f524058ec3051a175
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
- body = node.to_a.reverse[0]
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
- field_name = ancestor.children[3].source
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]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubocop-schema
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.7
4
+ version: 0.2.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - ceclinux