rubocop-schema 0.2.6 → 0.2.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rubocop-schema.rb +0 -2
- data/lib/rubocop/cop/style/migration_comments.rb +4 -3
- metadata +1 -3
- data/lib/rubocop/ast/builder.rb +0 -68
- data/lib/rubocop/ast/node/def_node.rb +0 -71
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 32935e4c25c7ff0b5e503227dfac62de32ceef8a
|
4
|
+
data.tar.gz: af233508c74921aaac137e05dd3dd7d72eee9934
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5ca7e8f31670278f2cfdad82ca4b94edb375b168750ffbb02a817d28925308ad4d5ce763c1e7e4bc2f1781778a7e4a2586af7404aa353379f815a521d2c26f33
|
7
|
+
data.tar.gz: 563d994ed24b1727abdbdaf2f2e4d975fb0a9f2a5ed84a5b81d417118ac48fa83947da878d4e43c39c243c4421e7dbb0cc032e948f6e244f524058ec3051a175
|
data/lib/rubocop-schema.rb
CHANGED
@@ -10,10 +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
|
-
|
13
|
+
body = node.to_a.reverse[0]
|
14
|
+
if body.type == :send
|
15
|
+
process_block_child_node(body)
|
15
16
|
else
|
16
|
-
|
17
|
+
body.each_child_node do |ancestor|
|
17
18
|
process_block_child_node(ancestor)
|
18
19
|
end
|
19
20
|
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.
|
4
|
+
version: 0.2.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ceclinux
|
@@ -32,8 +32,6 @@ extra_rdoc_files: []
|
|
32
32
|
files:
|
33
33
|
- config/default.yml
|
34
34
|
- lib/rubocop-schema.rb
|
35
|
-
- lib/rubocop/ast/builder.rb
|
36
|
-
- lib/rubocop/ast/node/def_node.rb
|
37
35
|
- lib/rubocop/cop/style/migration_comments.rb
|
38
36
|
- lib/rubocop/cop/style/schema_comments.rb
|
39
37
|
- lib/rubocop/style/inject.rb
|
data/lib/rubocop/ast/builder.rb
DELETED
@@ -1,68 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module RuboCop
|
4
|
-
module AST
|
5
|
-
# `RuboCop::Builder` is an AST builder that is utilized to let `Parser`
|
6
|
-
# generate ASTs with {RuboCop::AST::Node}.
|
7
|
-
#
|
8
|
-
# @example
|
9
|
-
# buffer = Parser::Source::Buffer.new('(string)')
|
10
|
-
# buffer.source = 'puts :foo'
|
11
|
-
#
|
12
|
-
# builder = RuboCop::Builder.new
|
13
|
-
# parser = Parser::CurrentRuby.new(builder)
|
14
|
-
# root_node = parser.parse(buffer)
|
15
|
-
class Builder < Parser::Builders::Default
|
16
|
-
NODE_MAP = {
|
17
|
-
AndNode => [:and],
|
18
|
-
ArgsNode => [:args],
|
19
|
-
ArrayNode => [:array],
|
20
|
-
DefNode => %i[def defs],
|
21
|
-
BlockNode => [:block],
|
22
|
-
CaseNode => [:case],
|
23
|
-
EnsureNode => [:ensure],
|
24
|
-
ForNode => [:for],
|
25
|
-
HashNode => [:hash],
|
26
|
-
IfNode => [:if],
|
27
|
-
KeywordSplatNode => [:kwsplat],
|
28
|
-
OrNode => [:or],
|
29
|
-
PairNode => [:pair],
|
30
|
-
ResbodyNode => [:resbody],
|
31
|
-
SendNode => %i[csend send],
|
32
|
-
SuperNode => %i[super zsuper],
|
33
|
-
UntilNode => %i[until until_post],
|
34
|
-
WhenNode => [:when],
|
35
|
-
WhileNode => %i[while while_post]
|
36
|
-
}.freeze
|
37
|
-
|
38
|
-
# Generates {Node} from the given information.
|
39
|
-
#
|
40
|
-
# @return [Node] the generated node
|
41
|
-
def n(type, children, source_map)
|
42
|
-
node_klass(type).new(type, children, location: source_map)
|
43
|
-
end
|
44
|
-
|
45
|
-
# TODO: Figure out what to do about literal encoding handling...
|
46
|
-
# More details here https://github.com/whitequark/parser/issues/283
|
47
|
-
def string_value(token)
|
48
|
-
value(token)
|
49
|
-
end
|
50
|
-
|
51
|
-
private
|
52
|
-
|
53
|
-
def node_klass(type)
|
54
|
-
node_map[type] || Node
|
55
|
-
end
|
56
|
-
|
57
|
-
# Take the human readable constant and generate a hash map where each
|
58
|
-
# (mapped) node type is a key with its constant as the value.
|
59
|
-
def node_map
|
60
|
-
@node_map ||= begin
|
61
|
-
NODE_MAP.each_pair.each_with_object({}) do |(klass, types), map|
|
62
|
-
types.each { |type| map[type] = klass }
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|
68
|
-
end
|
@@ -1,71 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module RuboCop
|
4
|
-
module AST
|
5
|
-
# A node extension for `def` nodes. This will be used in place of a plain
|
6
|
-
# node when the builder constructs the AST, making its methods available
|
7
|
-
# to all `def` nodes within RuboCop.
|
8
|
-
class DefNode < Node
|
9
|
-
include ParameterizedNode
|
10
|
-
include MethodIdentifierPredicates
|
11
|
-
|
12
|
-
# Checks whether this node body is a void context.
|
13
|
-
#
|
14
|
-
# @return [Boolean] whether the `def` node body is a void context
|
15
|
-
def void_context?
|
16
|
-
method?(:initialize) || assignment_method?
|
17
|
-
end
|
18
|
-
|
19
|
-
# The name of the defined method as a symbol.
|
20
|
-
#
|
21
|
-
# @return [Symbol] the name of the defined method
|
22
|
-
def method_name
|
23
|
-
node_parts[2]
|
24
|
-
end
|
25
|
-
|
26
|
-
# An array containing the arguments of the method definition.
|
27
|
-
#
|
28
|
-
# @return [Array<Node>] the arguments of the method definition
|
29
|
-
def arguments
|
30
|
-
node_parts[1]
|
31
|
-
end
|
32
|
-
|
33
|
-
# The body of the method definition.
|
34
|
-
#
|
35
|
-
# @note this can be either a `begin` node, if the method body contains
|
36
|
-
# multiple expressions, or any other node, if it contains a single
|
37
|
-
# expression.
|
38
|
-
#
|
39
|
-
# @return [Node] the body of the method definition
|
40
|
-
def body
|
41
|
-
node_parts[0]
|
42
|
-
end
|
43
|
-
|
44
|
-
# The receiver of the method definition, if any.
|
45
|
-
#
|
46
|
-
# @return [Node, nil] the receiver of the method definition, or `nil`.
|
47
|
-
def receiver
|
48
|
-
node_parts[3]
|
49
|
-
end
|
50
|
-
|
51
|
-
# Custom destructuring method. This can be used to normalize
|
52
|
-
# destructuring for different variations of the node.
|
53
|
-
#
|
54
|
-
# In this case, the `def` node destructures into:
|
55
|
-
#
|
56
|
-
# `method_name, arguments, body`
|
57
|
-
#
|
58
|
-
# while the `defs` node destructures into:
|
59
|
-
#
|
60
|
-
# `receiver, method_name, arguments, body`
|
61
|
-
#
|
62
|
-
# so we reverse the destructured array to get the optional receiver
|
63
|
-
# at the end, where it can be discarded.
|
64
|
-
#
|
65
|
-
# @return [Array] the different parts of the `def` or `defs` node
|
66
|
-
def node_parts
|
67
|
-
to_a.reverse
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|