rubocop 1.80.1 → 1.80.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5a047d4a83faf5e57dea4820484566645a9041e397a11cd995e9b5c558b0b657
4
- data.tar.gz: 80fea4c35729d9eab11bd0d26ec3c98b8127804dd0abf42fda5303065382b772
3
+ metadata.gz: 427aedeb12fa3d9d84e7ccd8ea4c125b418a3170c0f91d02e66ef8717006fc0a
4
+ data.tar.gz: f5a5b09520f27ed77d9cc5e2077ce9a55fa77db97bdd1d593e399551abd45bb8
5
5
  SHA512:
6
- metadata.gz: c971fe82aacd55238ee1b16f0329f4377491f0f1b175454d0cf3178a4fc759c625affbcca853a09dd106430f0e5462134e8ff2a2534ef898768121f3a482575e
7
- data.tar.gz: 47bd2586ce3a6568b2b3c6657e104104c30b0440ddac2ec64f96e70fe630e5afffa38fbf9be439ab3d8b7ef29e7b433537279d2a2cd0022a15cf6015d53b4484
6
+ metadata.gz: ddcf6fc4b8e900f900f5734c647b3d681d731d6d4bf37729c4960a751ace231d8835ca9800d4e499d1908f7e0474445bbf2490f5c8b9408d1301d6bff1196794
7
+ data.tar.gz: 94f856e78e6af3c0c78fd926268ae8349af663c2e7a1bc40a11842bb04db7a6baa1f239cb2c537ef8b442a4a76dfc09a8a7bfe10244abb2a78ed3b3b6600d38b
@@ -17,6 +17,7 @@ module RuboCop
17
17
  #
18
18
  # # good
19
19
  # CGI.escape('http://example.com')
20
+ # URI.encode_uri_component(uri) # Since Ruby 3.1
20
21
  # URI.encode_www_form([['example', 'param'], ['lang', 'en']])
21
22
  # URI.encode_www_form(page: 10, locale: 'en')
22
23
  # URI.encode_www_form_component('http://example.com')
@@ -27,6 +28,7 @@ module RuboCop
27
28
  #
28
29
  # # good
29
30
  # CGI.unescape(enc_uri)
31
+ # URI.decode_uri_component(uri) # Since Ruby 3.1
30
32
  # URI.decode_www_form(enc_uri)
31
33
  # URI.decode_www_form_component(enc_uri)
32
34
  class UriEscapeUnescape < Base
@@ -14,7 +14,7 @@ module RuboCop
14
14
  # method calls are assumed to return boolean values. The cop does not make an assessment
15
15
  # if the return type is unknown (non-predicate method calls, variables, etc.).
16
16
  #
17
- # NOTE: Operator methods (`def ==`, etc.) are ignored.
17
+ # NOTE: The `initialize` method and operator methods (`def ==`, etc.) are ignored.
18
18
  #
19
19
  # By default, the cop runs in `conservative` mode, which allows a method to be named
20
20
  # with a question mark as long as at least one return value is boolean. In `aggressive`
@@ -149,7 +149,8 @@ module RuboCop
149
149
  private
150
150
 
151
151
  def allowed?(node)
152
- allowed_method?(node.method_name) ||
152
+ node.method?(:initialize) ||
153
+ allowed_method?(node.method_name) ||
153
154
  matches_allowed_pattern?(node.method_name) ||
154
155
  allowed_bang_method?(node) ||
155
156
  node.operator_method? ||
@@ -24,9 +24,6 @@ module RuboCop
24
24
  (send `{(send _recv _msg) str array hash const #variable?} :[] ...)
25
25
  PATTERN
26
26
 
27
- # @!method method_node_and_args(node)
28
- def_node_matcher :method_node_and_args, '$(call _recv _msg $...)'
29
-
30
27
  # @!method rescue?(node)
31
28
  def_node_matcher :rescue?, '{^resbody ^^resbody}'
32
29
 
@@ -228,7 +225,7 @@ module RuboCop
228
225
 
229
226
  return check_unary(begin_node, node) if node.unary_operation?
230
227
 
231
- return unless method_call_with_redundant_parentheses?(node)
228
+ return unless method_call_with_redundant_parentheses?(begin_node, node)
232
229
  return if call_chain_starts_with_int?(begin_node, node) ||
233
230
  do_end_block_in_method_chain?(begin_node, node)
234
231
 
@@ -239,8 +236,7 @@ module RuboCop
239
236
  return if begin_node.chained?
240
237
 
241
238
  node = node.children.first while suspect_unary?(node)
242
-
243
- return if node.send_type? && !method_call_with_redundant_parentheses?(node)
239
+ return unless method_call_with_redundant_parentheses?(begin_node, node)
244
240
 
245
241
  offense(begin_node, 'a unary operation')
246
242
  end
@@ -302,13 +298,19 @@ module RuboCop
302
298
  end
303
299
  end
304
300
 
305
- def method_call_with_redundant_parentheses?(node)
306
- return false unless node.call_type?
301
+ def method_call_with_redundant_parentheses?(begin_node, node)
302
+ return false unless node.type?(:call, :super, :yield, :defined?)
307
303
  return false if node.prefix_not?
304
+ return true if singular_parenthesized_parent?(begin_node)
305
+
306
+ node.arguments.empty? || parentheses?(node) || square_brackets?(node)
307
+ end
308
308
 
309
- send_node, args = method_node_and_args(node)
309
+ def singular_parenthesized_parent?(begin_node)
310
+ return true unless begin_node.parent
311
+ return false if begin_node.parent.type?(:splat, :kwsplat)
310
312
 
311
- args.empty? || parentheses?(send_node) || square_brackets?(send_node)
313
+ parentheses?(begin_node) && begin_node.parent.children.one?
312
314
  end
313
315
 
314
316
  def only_begin_arg?(args)
@@ -262,8 +262,14 @@ module RuboCop
262
262
  end
263
263
 
264
264
  def dotless_operator_call?(method_call)
265
+ return true if dotless_operator_method?(method_call)
266
+
265
267
  method_call = method_call.parent while method_call.parent.send_type?
266
268
 
269
+ dotless_operator_method?(method_call)
270
+ end
271
+
272
+ def dotless_operator_method?(method_call)
267
273
  return false if method_call.loc.dot
268
274
 
269
275
  method_call.method?(:[]) || method_call.method?(:[]=) || method_call.operator_method?
@@ -141,22 +141,26 @@ module RuboCop
141
141
  end
142
142
 
143
143
  def replacement(parts)
144
- interpolated_parts = parts.map do |part|
145
- case part.type
146
- when :str
147
- adjust_str(part)
148
- when :dstr
149
- part.children.all?(&:str_type?) ? adjust_str(part) : part.value
150
- else
151
- "\#{#{part.source}}"
152
- end
153
- end
144
+ interpolated_parts = parts.map { |part| adjust_str(part) }
154
145
 
155
146
  "\"#{handle_quotes(interpolated_parts).join}\""
156
147
  end
157
148
 
158
- def adjust_str(node)
159
- single_quoted?(node) ? node.value.gsub(/(\\|")/, '\\\\\&') : node.value.inspect[1..-2]
149
+ def adjust_str(part)
150
+ case part.type
151
+ when :str
152
+ if single_quoted?(part)
153
+ part.value.gsub(/(\\|"|#\{|#@|#\$)/, '\\\\\&')
154
+ else
155
+ part.value.inspect[1..-2]
156
+ end
157
+ when :dstr, :begin
158
+ part.children.map do |child|
159
+ adjust_str(child)
160
+ end.join
161
+ else
162
+ "\#{#{part.source}}"
163
+ end
160
164
  end
161
165
 
162
166
  def handle_quotes(parts)
@@ -3,7 +3,7 @@
3
3
  module RuboCop
4
4
  # This module holds the RuboCop version information.
5
5
  module Version
6
- STRING = '1.80.1'
6
+ STRING = '1.80.2'
7
7
 
8
8
  MSG = '%<version>s (using %<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.80.1
4
+ version: 1.80.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bozhidar Batsov
@@ -9,7 +9,7 @@ authors:
9
9
  - Yuji Nakayama
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2025-08-27 00:00:00.000000000 Z
12
+ date: 2025-09-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: json
@@ -1090,7 +1090,7 @@ licenses:
1090
1090
  - MIT
1091
1091
  metadata:
1092
1092
  homepage_uri: https://rubocop.org/
1093
- changelog_uri: https://github.com/rubocop/rubocop/releases/tag/v1.80.1
1093
+ changelog_uri: https://github.com/rubocop/rubocop/releases/tag/v1.80.2
1094
1094
  source_code_uri: https://github.com/rubocop/rubocop/
1095
1095
  documentation_uri: https://docs.rubocop.org/rubocop/1.80/
1096
1096
  bug_tracker_uri: https://github.com/rubocop/rubocop/issues