rubocop-schema 0.1.1 → 0.1.2

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: 155fdd174382d598c435b7d5d9b1da411ee632cb
4
- data.tar.gz: 32acbf148e0da4263084877968f0aaf0e240aa66
3
+ metadata.gz: 4f943c9e09503c54a5191084a6fd9efde6f3eb46
4
+ data.tar.gz: 39ded4a657b5938b064329b78e70e9210f7fb364
5
5
  SHA512:
6
- metadata.gz: 948aaf8fcc4acf8c0a29938fd0b2b209b3c027db3c5b663a86d4fc0dbbf92c7249ebae49c9401fb0df70dabc024caa622a93bc360682235c88556aa3a5c42a20
7
- data.tar.gz: 410f6864cda125d1d25af14cc5b65ab98433e8da24129e5690fd508352ee6972378659662ffa664e2aba22695b7cb0af2ce1afd9fea19eeee0f332b726dc9c8f
6
+ metadata.gz: 2ada7044e3953025383a6dd4032bdceadfd64a811fc9e1219dc0adf707fa3bef93b215e3a82893e24485f8f82f1afd5c7af0f4eabdfc5a0b12f9a6fc5b7aa213
7
+ data.tar.gz: 2af0f83ccd7550d1c4f96270fcf9e53dfdc54f5ad87db9af328c5a248bbbb973367e0aadb317b36eb730f0a6cb649afc56caa7b86ab732b2db9bace2722974cc
@@ -0,0 +1,33 @@
1
+ module RuboCop
2
+ module Cop
3
+ module Style
4
+
5
+ class SchemaComments < Cop
6
+ include ConfigurableEnforcedStyle
7
+
8
+ MSG = 'Comment is obligatory.'.freeze
9
+ COMMON_DB_FIELDS = %w("deleted_at" "id" "creator_id" "deleter_id" "created_at" "updated_at").freeze
10
+
11
+ def on_block(node)
12
+ node.body.each_child_node do |ancestor|
13
+ process_block_child_node(ancestor)
14
+ end
15
+ end
16
+
17
+ private
18
+
19
+ def process_block_child_node(ancestor)
20
+
21
+ field_name = ancestor.children[2].source
22
+ return if COMMON_DB_FIELDS.include? field_name
23
+
24
+ last_child = ancestor.children[-1]
25
+ return if last_child.type == :hash && last_child.each_key.any? {|key| key.source == "comment"}
26
+
27
+ add_offense(ancestor, :expression)
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
33
+
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.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - ceclinux
@@ -31,6 +31,7 @@ extensions: []
31
31
  extra_rdoc_files: []
32
32
  files:
33
33
  - lib/rubocop-schema.rb
34
+ - lib/rubocop/cop/style/schema_comments.rb
34
35
  homepage: http://rubygems.org/gems/rubocop-schema
35
36
  licenses:
36
37
  - MIT