rubocop 1.81.7 → 1.82.0

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.
Files changed (82) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/config/default.yml +21 -5
  4. data/config/obsoletion.yml +4 -0
  5. data/lib/rubocop/cli.rb +2 -1
  6. data/lib/rubocop/comment_config.rb +62 -17
  7. data/lib/rubocop/config_loader.rb +2 -1
  8. data/lib/rubocop/config_loader_resolver.rb +2 -2
  9. data/lib/rubocop/cop/autocorrect_logic.rb +2 -0
  10. data/lib/rubocop/cop/correctors/alignment_corrector.rb +1 -3
  11. data/lib/rubocop/cop/gemspec/ruby_version_globals_usage.rb +10 -5
  12. data/lib/rubocop/cop/internal_affairs/location_exists.rb +28 -2
  13. data/lib/rubocop/cop/internal_affairs/node_pattern_groups/ast_processor.rb +1 -1
  14. data/lib/rubocop/cop/layout/empty_line_after_guard_clause.rb +3 -0
  15. data/lib/rubocop/cop/layout/end_alignment.rb +4 -0
  16. data/lib/rubocop/cop/layout/heredoc_argument_closing_parenthesis.rb +2 -2
  17. data/lib/rubocop/cop/layout/heredoc_indentation.rb +0 -4
  18. data/lib/rubocop/cop/layout/indentation_style.rb +1 -1
  19. data/lib/rubocop/cop/layout/line_continuation_spacing.rb +1 -1
  20. data/lib/rubocop/cop/layout/line_length.rb +7 -4
  21. data/lib/rubocop/cop/layout/rescue_ensure_alignment.rb +5 -3
  22. data/lib/rubocop/cop/layout/space_around_keyword.rb +1 -1
  23. data/lib/rubocop/cop/lint/circular_argument_reference.rb +47 -3
  24. data/lib/rubocop/cop/lint/cop_directive_syntax.rb +1 -1
  25. data/lib/rubocop/cop/lint/else_layout.rb +19 -0
  26. data/lib/rubocop/cop/lint/literal_as_condition.rb +4 -0
  27. data/lib/rubocop/cop/lint/literal_in_interpolation.rb +1 -1
  28. data/lib/rubocop/cop/lint/no_return_in_begin_end_blocks.rb +4 -0
  29. data/lib/rubocop/cop/lint/redundant_cop_disable_directive.rb +23 -9
  30. data/lib/rubocop/cop/lint/redundant_require_statement.rb +4 -2
  31. data/lib/rubocop/cop/lint/redundant_splat_expansion.rb +7 -1
  32. data/lib/rubocop/cop/lint/self_assignment.rb +9 -1
  33. data/lib/rubocop/cop/lint/unreachable_code.rb +5 -3
  34. data/lib/rubocop/cop/lint/useless_or.rb +15 -2
  35. data/lib/rubocop/cop/lint/utils/nil_receiver_checker.rb +1 -1
  36. data/lib/rubocop/cop/metrics/utils/abc_size_calculator.rb +4 -3
  37. data/lib/rubocop/cop/mixin/check_single_line_suitability.rb +0 -4
  38. data/lib/rubocop/cop/mixin/code_length.rb +1 -1
  39. data/lib/rubocop/cop/mixin/hash_shorthand_syntax.rb +1 -1
  40. data/lib/rubocop/cop/mixin/line_length_help.rb +21 -2
  41. data/lib/rubocop/cop/mixin/method_complexity.rb +1 -1
  42. data/lib/rubocop/cop/mixin/multiline_expression_indentation.rb +1 -1
  43. data/lib/rubocop/cop/mixin/multiline_literal_brace_layout.rb +1 -1
  44. data/lib/rubocop/cop/mixin/statement_modifier.rb +0 -6
  45. data/lib/rubocop/cop/mixin/trailing_comma.rb +4 -5
  46. data/lib/rubocop/cop/naming/method_name.rb +1 -1
  47. data/lib/rubocop/cop/style/bare_percent_literals.rb +1 -2
  48. data/lib/rubocop/cop/style/case_equality.rb +11 -13
  49. data/lib/rubocop/cop/style/class_and_module_children.rb +1 -0
  50. data/lib/rubocop/cop/style/conditional_assignment.rb +1 -11
  51. data/lib/rubocop/cop/style/constant_visibility.rb +3 -3
  52. data/lib/rubocop/cop/style/empty_method.rb +0 -6
  53. data/lib/rubocop/cop/style/endless_method.rb +2 -2
  54. data/lib/rubocop/cop/style/guard_clause.rb +0 -11
  55. data/lib/rubocop/cop/style/if_unless_modifier.rb +3 -3
  56. data/lib/rubocop/cop/style/method_call_with_args_parentheses/require_parentheses.rb +12 -1
  57. data/lib/rubocop/cop/style/method_call_with_args_parentheses.rb +17 -4
  58. data/lib/rubocop/cop/style/module_member_existence_check.rb +74 -0
  59. data/lib/rubocop/cop/style/multiline_method_signature.rb +0 -4
  60. data/lib/rubocop/cop/style/parallel_assignment.rb +2 -2
  61. data/lib/rubocop/cop/style/redundant_argument.rb +2 -0
  62. data/lib/rubocop/cop/style/redundant_percent_q.rb +1 -2
  63. data/lib/rubocop/cop/style/redundant_regexp_argument.rb +5 -0
  64. data/lib/rubocop/cop/style/redundant_sort.rb +7 -7
  65. data/lib/rubocop/cop/style/super_arguments.rb +2 -2
  66. data/lib/rubocop/cop/style/trailing_underscore_variable.rb +11 -11
  67. data/lib/rubocop/cop/util.rb +2 -3
  68. data/lib/rubocop/directive_comment.rb +46 -3
  69. data/lib/rubocop/formatter/disabled_config_formatter.rb +1 -0
  70. data/lib/rubocop/lsp/diagnostic.rb +12 -17
  71. data/lib/rubocop/lsp/routes.rb +9 -36
  72. data/lib/rubocop/lsp/runtime.rb +2 -2
  73. data/lib/rubocop/lsp/server.rb +2 -2
  74. data/lib/rubocop/magic_comment.rb +20 -0
  75. data/lib/rubocop/rake_task.rb +1 -1
  76. data/lib/rubocop/remote_config.rb +7 -8
  77. data/lib/rubocop/rspec/shared_contexts.rb +2 -2
  78. data/lib/rubocop/rspec/support.rb +1 -1
  79. data/lib/rubocop/target_ruby.rb +1 -1
  80. data/lib/rubocop/version.rb +1 -1
  81. data/lib/rubocop.rb +1 -0
  82. metadata +7 -6
@@ -11,13 +11,13 @@ module RuboCop
11
11
 
12
12
  CACHE_LIFETIME = 24 * 60 * 60
13
13
 
14
- def initialize(url, base_dir)
14
+ def initialize(url, cache_root)
15
15
  begin
16
16
  @uri = URI.parse(url)
17
17
  rescue URI::InvalidURIError
18
18
  raise ConfigNotFoundError, "Failed to resolve configuration: '#{url}' is not a valid URI"
19
19
  end
20
- @base_dir = base_dir
20
+ @cache_root = cache_root
21
21
  end
22
22
 
23
23
  def file
@@ -27,16 +27,17 @@ module RuboCop
27
27
  next if response.is_a?(Net::HTTPNotModified)
28
28
  next if response.is_a?(SocketError)
29
29
 
30
+ FileUtils.mkdir_p(File.dirname(cache_path))
30
31
  File.write(cache_path, response.body)
31
32
  end
32
33
 
33
34
  cache_path
34
35
  end
35
36
 
36
- def inherit_from_remote(file, path)
37
+ def inherit_from_remote(file)
37
38
  new_uri = @uri.dup
38
39
  new_uri.path.gsub!(%r{/[^/]*$}, "/#{file.delete_prefix('./')}")
39
- RemoteConfig.new(new_uri.to_s, File.dirname(path))
40
+ RemoteConfig.new(new_uri.to_s, @cache_root)
40
41
  end
41
42
 
42
43
  private
@@ -80,7 +81,7 @@ module RuboCop
80
81
  end
81
82
 
82
83
  def cache_path
83
- File.expand_path(".rubocop-#{cache_name_from_uri}", @base_dir)
84
+ @cache_path ||= File.expand_path(".rubocop-remote-#{cache_name_from_uri}", @cache_root)
84
85
  end
85
86
 
86
87
  def cache_path_exists?
@@ -97,9 +98,7 @@ module RuboCop
97
98
  end
98
99
 
99
100
  def cache_name_from_uri
100
- uri = cloned_url
101
- uri.query = nil
102
- uri.to_s.gsub!(/[^0-9A-Za-z]/, '-')
101
+ "#{Digest::MD5.hexdigest(@uri.to_s)}.yml"
103
102
  end
104
103
 
105
104
  def cloned_url
@@ -266,6 +266,6 @@ RSpec.shared_context 'ruby 3.4' do
266
266
  let(:ruby_version) { 3.4 }
267
267
  end
268
268
 
269
- RSpec.shared_context 'ruby 3.5' do
270
- let(:ruby_version) { 3.5 }
269
+ RSpec.shared_context 'ruby 4.0' do
270
+ let(:ruby_version) { 4.0 }
271
271
  end
@@ -30,5 +30,5 @@ RSpec.configure do |config|
30
30
  config.include_context 'ruby 3.2', :ruby32
31
31
  config.include_context 'ruby 3.3', :ruby33
32
32
  config.include_context 'ruby 3.4', :ruby34
33
- config.include_context 'ruby 3.5', :ruby35
33
+ config.include_context 'ruby 4.0', :ruby40
34
34
  end
@@ -4,7 +4,7 @@ module RuboCop
4
4
  # The kind of Ruby that code inspected by RuboCop is written in.
5
5
  # @api private
6
6
  class TargetRuby
7
- KNOWN_RUBIES = [2.0, 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 3.0, 3.1, 3.2, 3.3, 3.4, 3.5].freeze
7
+ KNOWN_RUBIES = [2.0, 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 3.0, 3.1, 3.2, 3.3, 3.4, 4.0].freeze
8
8
  DEFAULT_VERSION = 2.7
9
9
 
10
10
  OBSOLETE_RUBIES = {
@@ -3,7 +3,7 @@
3
3
  module RuboCop
4
4
  # This module holds the RuboCop version information.
5
5
  module Version
6
- STRING = '1.81.7'
6
+ STRING = '1.82.0'
7
7
 
8
8
  MSG = '%<version>s (using %<parser_version>s, ' \
9
9
  'rubocop-ast %<rubocop_ast_version>s, ' \
data/lib/rubocop.rb CHANGED
@@ -608,6 +608,7 @@ require_relative 'rubocop/cop/style/map_to_set'
608
608
  require_relative 'rubocop/cop/style/method_call_without_args_parentheses'
609
609
  require_relative 'rubocop/cop/style/method_call_with_args_parentheses'
610
610
  require_relative 'rubocop/cop/style/min_max_comparison'
611
+ require_relative 'rubocop/cop/style/module_member_existence_check'
611
612
  require_relative 'rubocop/cop/style/multiline_in_pattern_then'
612
613
  require_relative 'rubocop/cop/style/numbered_parameters'
613
614
  require_relative 'rubocop/cop/style/open_struct_use'
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.81.7
4
+ version: 1.82.0
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-10-31 00:00:00.000000000 Z
12
+ date: 2025-12-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: json
@@ -127,7 +127,7 @@ dependencies:
127
127
  requirements:
128
128
  - - ">="
129
129
  - !ruby/object:Gem::Version
130
- version: 1.47.1
130
+ version: 1.48.0
131
131
  - - "<"
132
132
  - !ruby/object:Gem::Version
133
133
  version: '2.0'
@@ -137,7 +137,7 @@ dependencies:
137
137
  requirements:
138
138
  - - ">="
139
139
  - !ruby/object:Gem::Version
140
- version: 1.47.1
140
+ version: 1.48.0
141
141
  - - "<"
142
142
  - !ruby/object:Gem::Version
143
143
  version: '2.0'
@@ -839,6 +839,7 @@ files:
839
839
  - lib/rubocop/cop/style/mixin_grouping.rb
840
840
  - lib/rubocop/cop/style/mixin_usage.rb
841
841
  - lib/rubocop/cop/style/module_function.rb
842
+ - lib/rubocop/cop/style/module_member_existence_check.rb
842
843
  - lib/rubocop/cop/style/multiline_block_chain.rb
843
844
  - lib/rubocop/cop/style/multiline_if_modifier.rb
844
845
  - lib/rubocop/cop/style/multiline_if_then.rb
@@ -1091,9 +1092,9 @@ licenses:
1091
1092
  - MIT
1092
1093
  metadata:
1093
1094
  homepage_uri: https://rubocop.org/
1094
- changelog_uri: https://github.com/rubocop/rubocop/releases/tag/v1.81.7
1095
+ changelog_uri: https://github.com/rubocop/rubocop/releases/tag/v1.82.0
1095
1096
  source_code_uri: https://github.com/rubocop/rubocop/
1096
- documentation_uri: https://docs.rubocop.org/rubocop/1.81/
1097
+ documentation_uri: https://docs.rubocop.org/rubocop/1.82/
1097
1098
  bug_tracker_uri: https://github.com/rubocop/rubocop/issues
1098
1099
  rubygems_mfa_required: 'true'
1099
1100
  rdoc_options: []