rubocop 1.63.1 → 1.63.2

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: 2e73eb2f54012899b388f6a92a079c80233fe1dfc570abfeedf2091cb0abc71d
4
- data.tar.gz: cc1ef25acb1541f1873ebeb945254c430b175b468bc9645000008a5f7d9aea88
3
+ metadata.gz: e3c5597599c7a09fcfeb128009d782a9bd47668a4eb373663498e1dd7ca0acb0
4
+ data.tar.gz: 3a24d87aef2c8900f5d39634234f900c33526b55a7c54f0a0937e7a195a672d0
5
5
  SHA512:
6
- metadata.gz: c4a4d23a528df832913cd6e469942415f2e9af4b2c8893862f7cd2dada8da960f8fbd3525934ab325d290a0161a576c38318222edc55e26a150596ca99235d11
7
- data.tar.gz: c84f81ba55dd33a44a42ea9851d910738e8faffc3a02b0e6095eb17b17e4e1bf5fa90a0db5aac365a58bde4ff748782f6d6941575fb506122bc4afd2627b966c
6
+ metadata.gz: c6ac27979bc5f662289a0e784985895f33610976405d23fc3d75424b2e3fe40f781b7228e07f9b2c4c8e9a8e9a93b3e4c60a88597de3616eab9f07df0f5de116
7
+ data.tar.gz: a5b834be33ea4c0f43c599d21da832bc7ca8927b1271101511de2b6f65ed9418f95140e8ad1902c80b8629bf29c5e0cdeba700b5e9abae9f311ea9ff9acf00bb
data/config/default.yml CHANGED
@@ -1703,7 +1703,6 @@ Lint/Debugger:
1703
1703
  DebuggerRequires:
1704
1704
  debug.rb:
1705
1705
  - debug/open
1706
- - debug/open_nonstop
1707
1706
  - debug/start
1708
1707
 
1709
1708
  Lint/DeprecatedClassMethods:
@@ -186,7 +186,9 @@ module RuboCop
186
186
  def add_global_offense(message = nil, severity: nil)
187
187
  severity = find_severity(nil, severity)
188
188
  message = find_message(nil, message)
189
- current_offenses << Offense.new(severity, Offense::NO_LOCATION, message, name, :unsupported)
189
+ range = Offense::NO_LOCATION
190
+ status = enabled_line?(range.line) ? :unsupported : :disabled
191
+ current_offenses << Offense.new(severity, range, message, name, status)
190
192
  end
191
193
 
192
194
  # Adds an offense on the specified range (or node with an expression)
@@ -47,8 +47,10 @@ module RuboCop
47
47
 
48
48
  def on_regexp(node)
49
49
  each_unsafe_regexp_range(node) do |loc|
50
+ next unless (replacement = regexp_range(loc.source))
51
+
50
52
  add_offense(loc) do |corrector|
51
- corrector.replace(loc, rewrite_regexp_range(loc.source))
53
+ corrector.replace(loc, replacement)
52
54
  end
53
55
  end
54
56
  end
@@ -99,10 +101,13 @@ module RuboCop
99
101
  end
100
102
  end
101
103
 
102
- def rewrite_regexp_range(source)
104
+ def regexp_range(source)
103
105
  open, close = source.split('-')
104
- first = [open, range_for(open).end]
105
- second = [range_for(close).begin, close]
106
+ return unless (open_range = range_for(open))
107
+ return unless (close_range = range_for(close))
108
+
109
+ first = [open, open_range.end]
110
+ second = [close_range.begin, close]
106
111
  "#{first.uniq.join('-')}#{second.uniq.join('-')}"
107
112
  end
108
113
  end
@@ -160,7 +160,7 @@ module RuboCop
160
160
  break_statement && !preceded_by_continue_statement?(break_statement)
161
161
  when :if
162
162
  check_if(node)
163
- when :case
163
+ when :case, :case_match
164
164
  check_case(node)
165
165
  else
166
166
  false
@@ -178,7 +178,13 @@ module RuboCop
178
178
  return false unless else_branch
179
179
  return false unless break_statement?(else_branch)
180
180
 
181
- node.when_branches.all? { |branch| branch.body && break_statement?(branch.body) }
181
+ branches = if node.case_type?
182
+ node.when_branches
183
+ else
184
+ node.in_pattern_branches
185
+ end
186
+
187
+ branches.all? { |branch| branch.body && break_statement?(branch.body) }
182
188
  end
183
189
 
184
190
  def preceded_by_continue_statement?(break_statement)
@@ -312,7 +312,8 @@ module RuboCop
312
312
  end
313
313
 
314
314
  def register_forward_block_arg_offense(add_parens, def_arguments_or_send, block_arg)
315
- return if target_ruby_version <= 3.0 || block_arg.source == '&' || explicit_block_name?
315
+ return if target_ruby_version <= 3.0 ||
316
+ block_arg.nil? || block_arg.source == '&' || explicit_block_name?
316
317
 
317
318
  add_offense(block_arg, message: BLOCK_MSG) do |corrector|
318
319
  add_parens_if_missing(def_arguments_or_send, corrector) if add_parens
@@ -20,8 +20,8 @@ module RuboCop
20
20
  #
21
21
  # [source,ruby]
22
22
  # ----
23
- # @dest = []
24
- # src.each { |e| @dest << e * 2 } # `src` method may mutate `@dest`
23
+ # ret = []
24
+ # src.each { |e| ret << e * 2 } # `<<` method may mutate `ret`
25
25
  #
26
26
  # dest = []
27
27
  # src.each { |e| dest << transform(e, dest) } # `transform` method may mutate `dest`
@@ -1,11 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- begin
4
- require 'bundler'
5
- rescue LoadError
6
- nil
7
- end
8
-
9
3
  module RuboCop
10
4
  # Encapsulation of a lockfile for use when checking for gems.
11
5
  # Does not actually resolve gems, just parses the lockfile.
@@ -13,7 +7,7 @@ module RuboCop
13
7
  class Lockfile
14
8
  # @param [String, Pathname, nil] lockfile_path
15
9
  def initialize(lockfile_path = nil)
16
- lockfile_path ||= defined?(Bundler) ? Bundler.default_lockfile : nil
10
+ lockfile_path ||= Bundler.default_lockfile if bundler_lock_parser_defined?
17
11
 
18
12
  @lockfile_path = lockfile_path
19
13
  end
@@ -66,14 +60,18 @@ module RuboCop
66
60
  def parser
67
61
  return @parser if defined?(@parser)
68
62
 
69
- @parser = if defined?(::Bundler) && @lockfile_path
63
+ @parser = if @lockfile_path
70
64
  begin
71
65
  lockfile = ::Bundler.read_file(@lockfile_path)
72
- lockfile ? ::Bundler::LockfileParser.new(lockfile) : nil
66
+ ::Bundler::LockfileParser.new(lockfile) if lockfile
73
67
  rescue ::Bundler::BundlerError
74
68
  nil
75
69
  end
76
70
  end
77
71
  end
72
+
73
+ def bundler_lock_parser_defined?
74
+ Object.const_defined?(:Bundler) && Bundler.const_defined?(:LockfileParser)
75
+ end
78
76
  end
79
77
  end
@@ -3,7 +3,7 @@
3
3
  module RuboCop
4
4
  # This module holds the RuboCop version information.
5
5
  module Version
6
- STRING = '1.63.1'
6
+ STRING = '1.63.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.63.1
4
+ version: 1.63.2
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: 2024-04-10 00:00:00.000000000 Z
13
+ date: 2024-04-16 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: json
@@ -1032,7 +1032,7 @@ licenses:
1032
1032
  - MIT
1033
1033
  metadata:
1034
1034
  homepage_uri: https://rubocop.org/
1035
- changelog_uri: https://github.com/rubocop/rubocop/releases/tag/v1.63.1
1035
+ changelog_uri: https://github.com/rubocop/rubocop/releases/tag/v1.63.2
1036
1036
  source_code_uri: https://github.com/rubocop/rubocop/
1037
1037
  documentation_uri: https://docs.rubocop.org/rubocop/1.63/
1038
1038
  bug_tracker_uri: https://github.com/rubocop/rubocop/issues