rubocop-performance 1.11.4 → 1.11.5

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: 9f8e6344d490eed1972435e9ce89e171634bff029196b42987d02ee02745ddce
4
- data.tar.gz: 863428f02b2e9e387f40bc534775928035ca945d08cfdb8b6602b2765e67f074
3
+ metadata.gz: 4fffd38c1ed7da6f4ff4f67b3f1d7d08bc60e8871dc22d4ac266de6facc04fcf
4
+ data.tar.gz: e0de1a9ec946e37b2654390d4b46a0b9f0e1afbc37fec464c6fd78001ad5e509
5
5
  SHA512:
6
- metadata.gz: fb7b9ea8f9626ea64dd44af1c3f6cc2e6141fdf6dc50b4f7aca09c88c11fe68b54a808cfaa2b0bed3a429f4614e85f84a724f833d5c767d7dc9fdc1f1a082014
7
- data.tar.gz: a2b8d58a302ea4070e1ce702263806ca1fe3b9d7e3c9944156299c28d8df9ad311d321d202b4cdf02723dc6a331b6817604afea9d7e684e2c9a3cf4300763460
6
+ metadata.gz: 4225a879e2e0421438be5d17bb38d982901709c809ed7ccda3a0095affaf77a707c5fb5657ee61b123546860f1e9f0bcf783ed706b8b17fba9114588a16b4653
7
+ data.tar.gz: 3af998bbda7046ae5a55f06bb1ecc941dff48901d94a791fd81963cc1d76adf39524600c7ff4633c3dc06f925a2d8ea7f57716f51de2079e971c10b6194e40bb
@@ -66,7 +66,7 @@ module RuboCop
66
66
  chained_method = compact_node.parent
67
67
  compact_method_range = compact_node.loc.selector
68
68
 
69
- if compact_node.multiline? && chained_method&.loc.respond_to?(:selector) &&
69
+ if compact_node.multiline? && chained_method&.loc.respond_to?(:selector) && chained_method.dot? &&
70
70
  !invoke_method_after_map_compact_on_same_line?(compact_node, chained_method)
71
71
  compact_method_range = range_by_whole_lines(compact_method_range, include_final_newline: true)
72
72
  else
@@ -74,12 +74,27 @@ module RuboCop
74
74
 
75
75
  def new_argument(block_argument, block_body)
76
76
  if block_argument.source == block_body.receiver.source
77
- block_body.first_argument.source
77
+ rhs = block_body.first_argument
78
+ return if use_block_argument_in_method_argument_of_operand?(block_argument, rhs)
79
+
80
+ rhs.source
78
81
  elsif block_argument.source == block_body.first_argument.source
79
- block_body.receiver.source
82
+ lhs = block_body.receiver
83
+ return if use_block_argument_in_method_argument_of_operand?(block_argument, lhs)
84
+
85
+ lhs.source
80
86
  end
81
87
  end
82
88
 
89
+ def use_block_argument_in_method_argument_of_operand?(block_argument, operand)
90
+ return false unless operand.send_type?
91
+
92
+ arguments = operand.arguments
93
+ arguments.inject(arguments.map(&:source)) do |operand_sources, argument|
94
+ operand_sources + argument.each_descendant(:lvar).map(&:source)
95
+ end.any?(block_argument.source)
96
+ end
97
+
83
98
  def offense_range(node)
84
99
  node.send_node.loc.selector.join(node.source_range.end)
85
100
  end
@@ -4,7 +4,7 @@ module RuboCop
4
4
  module Performance
5
5
  # This module holds the RuboCop Performance version information.
6
6
  module Version
7
- STRING = '1.11.4'
7
+ STRING = '1.11.5'
8
8
 
9
9
  def self.document_version
10
10
  STRING.match('\d+\.\d+').to_s
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubocop-performance
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.11.4
4
+ version: 1.11.5
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: 2021-07-07 00:00:00.000000000 Z
13
+ date: 2021-08-18 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rubocop