rubocop-ast 0.5.0 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rubocop/ast.rb +1 -0
- data/lib/rubocop/ast/node/mixin/method_dispatch_node.rb +14 -24
- data/lib/rubocop/ast/rubocop_compatibility.rb +31 -0
- data/lib/rubocop/ast/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f71ef8c3ea38e4fc2ef139e7ec61bc6811cc4aea1e3cc4031055ca49aa2a20b3
|
4
|
+
data.tar.gz: 3b338905a203f204230099806070e653785e0999d196b09d6a2af3ed69450c10
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 61df3d081d020042e922967ed5653781f5c589c9960dc9666d17a339b4c09f57cb948df4be2356bbc175598d4cbbc9f10329e2020f468f1812ce1da383a2768f
|
7
|
+
data.tar.gz: fc5711d88c212f81d4bc0e9aedf461de610d2903a22e217b11ccc95fbabad0170c1a0149b79f49db8475e848cee2b86924f302ea4172e67eee5b7b6e2ab38229
|
data/lib/rubocop/ast.rb
CHANGED
@@ -63,6 +63,7 @@ require_relative 'ast/node/while_node'
|
|
63
63
|
require_relative 'ast/node/yield_node'
|
64
64
|
require_relative 'ast/builder'
|
65
65
|
require_relative 'ast/processed_source'
|
66
|
+
require_relative 'ast/rubocop_compatibility'
|
66
67
|
require_relative 'ast/token'
|
67
68
|
require_relative 'ast/traversal'
|
68
69
|
require_relative 'ast/version'
|
@@ -42,7 +42,7 @@ module RuboCop
|
|
42
42
|
#
|
43
43
|
# @return [Boolean] whether the dispatched method is a macro method
|
44
44
|
def macro?
|
45
|
-
!receiver &&
|
45
|
+
!receiver && in_macro_scope?
|
46
46
|
end
|
47
47
|
|
48
48
|
# Checks whether the dispatched method is an access modifier.
|
@@ -222,31 +222,21 @@ module RuboCop
|
|
222
222
|
|
223
223
|
private
|
224
224
|
|
225
|
-
def_node_matcher :
|
226
|
-
{
|
227
|
-
|
228
|
-
|
229
|
-
|
225
|
+
def_node_matcher :in_macro_scope?, <<~PATTERN
|
226
|
+
{
|
227
|
+
root? # Either a root node,
|
228
|
+
^{ # or the parent is...
|
229
|
+
sclass class module class_constructor? # a class-like node
|
230
|
+
[ { # or some "wrapper"
|
231
|
+
kwbegin begin block
|
232
|
+
(if _condition <%0 _>) # note: we're excluding the condition of `if` nodes
|
233
|
+
}
|
234
|
+
#in_macro_scope? # that is itself in a macro scope
|
235
|
+
]
|
236
|
+
}
|
237
|
+
}
|
230
238
|
PATTERN
|
231
239
|
|
232
|
-
# Check if a node's parent is a kwbegin wrapper within a macro scope
|
233
|
-
#
|
234
|
-
# @param parent [Node] parent of the node being checked
|
235
|
-
#
|
236
|
-
# @return [Boolean] true if the parent is a kwbegin in a macro scope
|
237
|
-
def macro_kwbegin_wrapper?(parent)
|
238
|
-
parent.kwbegin_type? && macro_scope?(parent)
|
239
|
-
end
|
240
|
-
|
241
|
-
# Check if a node does not have a parent
|
242
|
-
#
|
243
|
-
# @param node [Node]
|
244
|
-
#
|
245
|
-
# @return [Boolean] if the parent is nil
|
246
|
-
def root_node?(node)
|
247
|
-
node.parent.nil?
|
248
|
-
end
|
249
|
-
|
250
240
|
def_node_matcher :adjacent_def_modifier?, <<~PATTERN
|
251
241
|
(send nil? _ ({def defs} ...))
|
252
242
|
PATTERN
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RuboCop
|
4
|
+
# ...
|
5
|
+
module AST
|
6
|
+
# Responsible for compatibility with main gem
|
7
|
+
# @api private
|
8
|
+
module RuboCopCompatibility
|
9
|
+
INCOMPATIBLE_COPS = {
|
10
|
+
'0.89.0' => 'Layout/LineLength',
|
11
|
+
'0.92.0' => 'Style/MixinUsage'
|
12
|
+
}.freeze
|
13
|
+
def rubocop_loaded
|
14
|
+
loaded = Gem::Version.new(RuboCop::Version::STRING)
|
15
|
+
incompatible = INCOMPATIBLE_COPS.select do |k, _v|
|
16
|
+
loaded < Gem::Version.new(k)
|
17
|
+
end.values
|
18
|
+
return if incompatible.empty?
|
19
|
+
|
20
|
+
warn <<~WARNING
|
21
|
+
*** WARNING – Incompatible versions of `rubocop` and `rubocop-ast`
|
22
|
+
You may encounter issues with the following \
|
23
|
+
Cop#{'s' if incompatible.size > 1}: #{incompatible.join(', ')}
|
24
|
+
Please upgrade rubocop to at least v#{INCOMPATIBLE_COPS.keys.last}
|
25
|
+
WARNING
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
extend RuboCopCompatibility
|
30
|
+
end
|
31
|
+
end
|
data/lib/rubocop/ast/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubocop-ast
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bozhidar Batsov
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2020-09-
|
13
|
+
date: 2020-09-25 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: parser
|
@@ -116,6 +116,7 @@ files:
|
|
116
116
|
- lib/rubocop/ast/node/yield_node.rb
|
117
117
|
- lib/rubocop/ast/node_pattern.rb
|
118
118
|
- lib/rubocop/ast/processed_source.rb
|
119
|
+
- lib/rubocop/ast/rubocop_compatibility.rb
|
119
120
|
- lib/rubocop/ast/sexp.rb
|
120
121
|
- lib/rubocop/ast/token.rb
|
121
122
|
- lib/rubocop/ast/traversal.rb
|