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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 329f01e23bc173bdcfec3cec5ef0eaf411f9328dbb7bef472e9ea119a2989427
4
- data.tar.gz: 9208c40cf5063f525dcdf44eb43d65e05814fa76931f52c3015c391e3e99b77b
3
+ metadata.gz: f71ef8c3ea38e4fc2ef139e7ec61bc6811cc4aea1e3cc4031055ca49aa2a20b3
4
+ data.tar.gz: 3b338905a203f204230099806070e653785e0999d196b09d6a2af3ed69450c10
5
5
  SHA512:
6
- metadata.gz: 487a0aad608835a2a7b25f10d74e5430dded65f3c444dd5bfa3747b553c4811b09768c6966db4815adb1d529e4677930ed19e1a6b57ae7d0844f6d590265da55
7
- data.tar.gz: c054ab24f0760a913e605fb8754e2c76faf993cc965695bafcba8c9e3b5ed333b20a3a6df7d442be7aa234ff98e881617f824bf9e8b38b8e9d86d72dc8e78ca0
6
+ metadata.gz: 61df3d081d020042e922967ed5653781f5c589c9960dc9666d17a339b4c09f57cb948df4be2356bbc175598d4cbbc9f10329e2020f468f1812ce1da383a2768f
7
+ data.tar.gz: fc5711d88c212f81d4bc0e9aedf461de610d2903a22e217b11ccc95fbabad0170c1a0149b79f49db8475e848cee2b86924f302ea4172e67eee5b7b6e2ab38229
@@ -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 && macro_scope?
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 :macro_scope?, <<~PATTERN
226
- {^{({sclass class module block} ...) class_constructor?}
227
- ^^{({sclass class module block} ... ({begin if} ...)) class_constructor?}
228
- ^#macro_kwbegin_wrapper?
229
- #root_node?}
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
@@ -3,7 +3,7 @@
3
3
  module RuboCop
4
4
  module AST
5
5
  module Version
6
- STRING = '0.5.0'
6
+ STRING = '0.5.1'
7
7
  end
8
8
  end
9
9
  end
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.0
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-24 00:00:00.000000000 Z
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