rubocop 1.55.0 → 1.55.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: 7bfd5d73e8097398116fc389fa55f96eca51b61c95a5e9e4654d7eeebaeef985
4
- data.tar.gz: a2cf8206a9896953e85516ebdc00f673a5852eb9613e877fee6b43058f7ef080
3
+ metadata.gz: 4c1de4039df4f7edef2ab28f9623efa0f1d4d22e7f05d9cbd68bee76cb5216bf
4
+ data.tar.gz: 3a0b84d52ba7fabd1980cfbb4d351a1d8ac2b5a1bd38608194529e34124ad603
5
5
  SHA512:
6
- metadata.gz: 454b6be8363e0a91226348e2543587d5e6c3503bdaa9b2c0287f1a1e347f9a315c8f8337c5762e59f83f7406a797645ebef7e16a896694da29cb751a658e5579
7
- data.tar.gz: 388fe4a1934bf7659148ce32a2837f5ff0822babc1e17abd1a2c4f8138e6a839a7c4f304202e7e712763dbc23fadee4c92412554cbe699a8f81810e602d62f49
6
+ metadata.gz: c4b5c017d22990f0f7627663d532d793cf193a97afc0de8dca538b86e35fa26210df1e871e705e3b4d9302ba0a46d5c1a7910368c083520ae62cd2facd21be0c
7
+ data.tar.gz: 2e73d75f974b9f85a27e024e4c67bfc907a279f5fd07100996f04080361e9c1258b84eca28fe8352c594e5c815a6c748db786bbe67502bf887d86cfd201b8cc6
@@ -53,7 +53,7 @@ module RuboCop
53
53
  # List of cops that should not try to autocorrect at the same
54
54
  # time as this cop
55
55
  #
56
- # @return [Array<RuboCop::Cop::Cop>]
56
+ # @return [Array<RuboCop::Cop::Base>]
57
57
  #
58
58
  # @api public
59
59
  def self.autocorrect_incompatible_with
@@ -19,7 +19,15 @@ module RuboCop
19
19
  #
20
20
  # gem 'rspec'
21
21
  #
22
- # # good only if TreatCommentsAsGroupSeparators is true
22
+ # @example TreatCommentsAsGroupSeparators: true (default)
23
+ # # good
24
+ # # For code quality
25
+ # gem 'rubocop'
26
+ # # For tests
27
+ # gem 'rspec'
28
+ #
29
+ # @example TreatCommentsAsGroupSeparators: false
30
+ # # bad
23
31
  # # For code quality
24
32
  # gem 'rubocop'
25
33
  # # For tests
@@ -45,7 +45,15 @@ module RuboCop
45
45
  #
46
46
  # spec.add_runtime_dependency 'rspec'
47
47
  #
48
- # # good only if TreatCommentsAsGroupSeparators is true
48
+ # @example TreatCommentsAsGroupSeparators: true (default)
49
+ # # good
50
+ # # For code quality
51
+ # spec.add_dependency 'rubocop'
52
+ # # For tests
53
+ # spec.add_dependency 'rspec'
54
+ #
55
+ # @example TreatCommentsAsGroupSeparators: false
56
+ # # bad
49
57
  # # For code quality
50
58
  # spec.add_dependency 'rubocop'
51
59
  # # For tests
@@ -46,7 +46,8 @@ module RuboCop
46
46
 
47
47
  EXPECT_OFFENSE_INCORRECT_DESCRIPTIONS = [
48
48
  /^(does not|doesn't) (register|find|flag|report)/,
49
- /^(does not|doesn't) add (a|an|any )?offense/
49
+ /^(does not|doesn't) add (a|an|any )?offense/,
50
+ /^accepts\b/
50
51
  ].freeze
51
52
 
52
53
  EXPECT_NO_CORRECTIONS_INCORRECT_DESCRIPTIONS = [/^(auto[- ]?)?correct/].freeze
@@ -19,7 +19,7 @@ module RuboCop
19
19
  # foo &. bar
20
20
  # foo &. bar&. buzz
21
21
  # RuboCop:: Cop
22
- # RuboCop:: Cop:: Cop
22
+ # RuboCop:: Cop:: Base
23
23
  # :: RuboCop::Cop
24
24
  #
25
25
  # # good
@@ -31,7 +31,7 @@ module RuboCop
31
31
  # foo&.bar
32
32
  # foo&.bar&.buzz
33
33
  # RuboCop::Cop
34
- # RuboCop::Cop::Cop
34
+ # RuboCop::Cop::Base
35
35
  # ::RuboCop::Cop
36
36
  #
37
37
  class SpaceAroundMethodCallOperator < Base
@@ -19,7 +19,7 @@ module RuboCop
19
19
 
20
20
  # @!method non_public_modifier?(node)
21
21
  def_node_matcher :non_public_modifier?, <<~PATTERN
22
- (send nil? {:private :protected} ({def defs} ...))
22
+ (send nil? {:private :protected :private_class_method} ({def defs} ...))
23
23
  PATTERN
24
24
  end
25
25
  end
@@ -240,14 +240,14 @@ module RuboCop
240
240
  class SendNodeClassifier
241
241
  extend NodePattern::Macros
242
242
 
243
- # @!method find_forwarded_rest_arg(node, rest_name)
244
- def_node_search :find_forwarded_rest_arg, '(splat (lvar %1))'
243
+ # @!method forwarded_rest_arg?(node, rest_name)
244
+ def_node_matcher :forwarded_rest_arg?, '(splat (lvar %1))'
245
245
 
246
- # @!method find_forwarded_kwrest_arg(node, kwrest_name)
247
- def_node_search :find_forwarded_kwrest_arg, '(kwsplat (lvar %1))'
246
+ # @!method extract_forwarded_kwrest_arg(node, kwrest_name)
247
+ def_node_matcher :extract_forwarded_kwrest_arg, '(hash <$(kwsplat (lvar %1)) ...>)'
248
248
 
249
- # @!method find_forwarded_block_arg(node, block_name)
250
- def_node_search :find_forwarded_block_arg, '(block_pass {(lvar %1) nil?})'
249
+ # @!method forwarded_block_arg?(node, block_name)
250
+ def_node_matcher :forwarded_block_arg?, '(block_pass {(lvar %1) nil?})'
251
251
 
252
252
  def initialize(def_node, send_node, referenced_lvars, forwardable_args, **config)
253
253
  @def_node = def_node
@@ -262,19 +262,19 @@ module RuboCop
262
262
  def forwarded_rest_arg
263
263
  return nil if referenced_rest_arg?
264
264
 
265
- find_forwarded_rest_arg(@send_node, @rest_arg_name).first
265
+ arguments.find { |arg| forwarded_rest_arg?(arg, @rest_arg_name) }
266
266
  end
267
267
 
268
268
  def forwarded_kwrest_arg
269
269
  return nil if referenced_kwrest_arg?
270
270
 
271
- find_forwarded_kwrest_arg(@send_node, @kwrest_arg_name).first
271
+ arguments.filter_map { |arg| extract_forwarded_kwrest_arg(arg, @kwrest_arg_name) }.first
272
272
  end
273
273
 
274
274
  def forwarded_block_arg
275
275
  return nil if referenced_block_arg?
276
276
 
277
- find_forwarded_block_arg(@send_node, @block_arg_name).first
277
+ arguments.find { |arg| forwarded_block_arg?(arg, @block_arg_name) }
278
278
  end
279
279
 
280
280
  def classification
@@ -289,6 +289,10 @@ module RuboCop
289
289
 
290
290
  private
291
291
 
292
+ def arguments
293
+ @send_node.arguments
294
+ end
295
+
292
296
  def referenced_rest_arg?
293
297
  @referenced_lvars.include?(@rest_arg_name)
294
298
  end
@@ -40,7 +40,7 @@ module RuboCop
40
40
  def on_class(node)
41
41
  begin_node = node.child_nodes.find(&:begin_type?) || node
42
42
  begin_node.each_child_node(:send).select(&:macro?).each do |macro|
43
- next unless MIXIN_METHODS.include?(macro.method_name)
43
+ next if !MIXIN_METHODS.include?(macro.method_name) || macro.arguments.empty?
44
44
 
45
45
  check(macro)
46
46
  end
@@ -77,6 +77,8 @@ module RuboCop
77
77
  private
78
78
 
79
79
  def nil_node_at_the_end_of_method_body(body)
80
+ return body if body.nil_type?
81
+ return unless body.begin_type?
80
82
  return unless (last_child = body.children.last)
81
83
 
82
84
  last_child if last_child.is_a?(AST::Node) && last_child.nil_type?
@@ -119,9 +119,7 @@ module RuboCop
119
119
  end
120
120
 
121
121
  def for_assignment_node
122
- return nil unless node.parent&.for_type?
123
-
124
- node.parent
122
+ node.ancestors.find(&:for_type?)
125
123
  end
126
124
 
127
125
  def find_multiple_assignment_node(grandparent_node)
@@ -3,7 +3,7 @@
3
3
  module RuboCop
4
4
  # This module holds the RuboCop version information.
5
5
  module Version
6
- STRING = '1.55.0'
6
+ STRING = '1.55.1'
7
7
 
8
8
  MSG = '%<version>s (using Parser %<parser_version>s, ' \
9
9
  'rubocop-ast %<rubocop_ast_version>s, ' \
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubocop
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.55.0
4
+ version: 1.55.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bozhidar Batsov
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: exe
12
12
  cert_chain: []
13
- date: 2023-07-25 00:00:00.000000000 Z
13
+ date: 2023-07-31 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: json