rubocop-schema 0.2.3 → 0.2.4

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: 148ecc639d19c95ad9ec4b21ee49c763e093a597
4
- data.tar.gz: bf9b2da5ceb23d69bca5c5244c3ae260d0fa98f9
3
+ metadata.gz: 833b790ca5651e145da936dc80d540d232203a83
4
+ data.tar.gz: d0853c8fe99c130c26ae10a2f95721e4cceb49bb
5
5
  SHA512:
6
- metadata.gz: 2f61d15d15a0f07f40fbe6746178b736d14824ad7dbb8d2743e07bf19ee539c529b0933f909037e4b520248b5e3e38ac2260fa10493498ad8699d4e30b3e8703
7
- data.tar.gz: 628d8857ed371a6eaaacda512eaaef049987311b41548a681571a1659548da19519691fc9f5ef394436b6291ef3e50188e38869b3780548bf45615e90a5aa5ad
6
+ metadata.gz: f223f46221c6e15c73e7431425ffbcc98b44d5d1199d9bd5fe7c3925ef83dab9216aa51c3a5335ce76247b0dbd73a9d2f94bb7a88d34795336b0ecc879fb5b95
7
+ data.tar.gz: 95933bc359613a1654d4860af6c54bd840c0b713c619023e135101a3855be9db8b3a8130b57fe448fb745c3e3edf17fe3157d3b717fe4112e729a71ea771c524
@@ -3,3 +3,4 @@ require 'rubocop/style/inject'
3
3
  RuboCop::Style::Inject.defaults!
4
4
 
5
5
  require 'rubocop/cop/style/schema_comments'
6
+ require 'rubocop/cop/style/migration_comments'
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+ module RuboCop
3
+ module Cop
4
+ module Style
5
+
6
+ class MigrationComments < Cop
7
+ include ConfigurableEnforcedStyle
8
+
9
+ MSG = 'Comment is obligatory.'.freeze
10
+ COMMON_DB_FIELDS = %w(:deleted_at :id :creator_id :deleter_id :created_at :updated_at).freeze
11
+
12
+ def on_def(node)
13
+ if node.body.type == :send
14
+ process_block_child_node(node.body)
15
+ else
16
+ node.body.each_child_node do |ancestor|
17
+ process_block_child_node(ancestor)
18
+ end
19
+ end
20
+ end
21
+
22
+ private
23
+
24
+ def process_block_child_node(ancestor)
25
+ field_name = ancestor.children[3].source
26
+ return if COMMON_DB_FIELDS.include? field_name
27
+
28
+ last_child = ancestor.children[-1]
29
+ return if last_child.type == :hash && last_child.each_key.any? {|key| [":comment", "comment"].include? key.source}
30
+
31
+ add_offense(ancestor, :expression)
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
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.3
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - ceclinux
@@ -32,6 +32,7 @@ extra_rdoc_files: []
32
32
  files:
33
33
  - config/default.yml
34
34
  - lib/rubocop-schema.rb
35
+ - lib/rubocop/cop/style/migration_comments.rb
35
36
  - lib/rubocop/cop/style/schema_comments.rb
36
37
  - lib/rubocop/style/inject.rb
37
38
  homepage: http://rubygems.org/gems/rubocop-schema