rubocop 1.59.0 → 1.60.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE.txt +1 -1
  3. data/README.md +3 -3
  4. data/config/default.yml +3 -1
  5. data/lib/rubocop/config.rb +0 -2
  6. data/lib/rubocop/config_loader.rb +0 -1
  7. data/lib/rubocop/config_validator.rb +0 -2
  8. data/lib/rubocop/cop/base.rb +6 -0
  9. data/lib/rubocop/cop/exclude_limit.rb +1 -1
  10. data/lib/rubocop/cop/internal_affairs/example_description.rb +4 -4
  11. data/lib/rubocop/cop/layout/end_alignment.rb +5 -1
  12. data/lib/rubocop/cop/layout/first_array_element_indentation.rb +16 -1
  13. data/lib/rubocop/cop/layout/line_continuation_leading_space.rb +1 -1
  14. data/lib/rubocop/cop/layout/redundant_line_break.rb +5 -1
  15. data/lib/rubocop/cop/lint/literal_assignment_in_condition.rb +12 -5
  16. data/lib/rubocop/cop/lint/shadowed_argument.rb +1 -0
  17. data/lib/rubocop/cop/lint/syntax.rb +6 -3
  18. data/lib/rubocop/cop/mixin/configurable_formatting.rb +1 -0
  19. data/lib/rubocop/cop/naming/block_forwarding.rb +10 -2
  20. data/lib/rubocop/cop/security/open.rb +2 -2
  21. data/lib/rubocop/cop/style/arguments_forwarding.rb +60 -12
  22. data/lib/rubocop/cop/style/collection_compact.rb +11 -2
  23. data/lib/rubocop/cop/style/conditional_assignment.rb +1 -1
  24. data/lib/rubocop/cop/style/each_for_simple_loop.rb +7 -7
  25. data/lib/rubocop/cop/style/eval_with_location.rb +0 -11
  26. data/lib/rubocop/cop/style/hash_each_methods.rb +29 -8
  27. data/lib/rubocop/cop/style/identical_conditional_branches.rb +4 -1
  28. data/lib/rubocop/cop/style/invertible_unless_condition.rb +39 -2
  29. data/lib/rubocop/cop/style/map_to_hash.rb +9 -5
  30. data/lib/rubocop/cop/style/method_call_with_args_parentheses/omit_parentheses.rb +13 -5
  31. data/lib/rubocop/cop/style/method_call_with_args_parentheses.rb +1 -3
  32. data/lib/rubocop/cop/style/multiline_ternary_operator.rb +1 -3
  33. data/lib/rubocop/cop/style/numeric_literal_prefix.rb +1 -1
  34. data/lib/rubocop/cop/style/parallel_assignment.rb +2 -2
  35. data/lib/rubocop/cop/style/parentheses_around_condition.rb +8 -0
  36. data/lib/rubocop/cop/style/redundant_each.rb +7 -4
  37. data/lib/rubocop/cop/style/redundant_line_continuation.rb +8 -1
  38. data/lib/rubocop/cop/style/redundant_parentheses.rb +18 -2
  39. data/lib/rubocop/cop/style/slicing_with_range.rb +76 -10
  40. data/lib/rubocop/cop/style/symbol_proc.rb +36 -0
  41. data/lib/rubocop/cops_documentation_generator.rb +11 -1
  42. data/lib/rubocop/ext/regexp_node.rb +9 -4
  43. data/lib/rubocop/formatter/disabled_config_formatter.rb +17 -6
  44. data/lib/rubocop/formatter/json_formatter.rb +0 -1
  45. data/lib/rubocop/formatter.rb +1 -1
  46. data/lib/rubocop/lsp/routes.rb +1 -1
  47. data/lib/rubocop/options.rb +0 -8
  48. data/lib/rubocop/rspec/shared_contexts.rb +6 -0
  49. data/lib/rubocop/rspec/support.rb +1 -0
  50. data/lib/rubocop/server/cache.rb +1 -2
  51. data/lib/rubocop/server/client_command/exec.rb +0 -1
  52. data/lib/rubocop/server/server_command/exec.rb +0 -1
  53. data/lib/rubocop/version.rb +1 -1
  54. metadata +11 -11
  55. /data/lib/rubocop/formatter/{git_hub_actions_formatter.rb → github_actions_formatter.rb} +0 -0
@@ -30,7 +30,8 @@ module RuboCop
30
30
  @files_with_offenses ||= {}
31
31
  end
32
32
 
33
- def file_started(_file, _file_info)
33
+ def file_started(_file, options)
34
+ @config_for_pwd = options[:config_store].for_pwd
34
35
  @exclude_limit_option = @options[:exclude_limit]
35
36
  @exclude_limit = Integer(@exclude_limit_option ||
36
37
  RuboCop::Options::DEFAULT_MAXIMUM_EXCLUSION_ITEMS)
@@ -115,9 +116,13 @@ module RuboCop
115
116
  def set_max(cfg, cop_name)
116
117
  return unless cfg[:exclude_limit]
117
118
 
118
- # In case auto_gen_only_exclude is set, only modify the maximum if the
119
- # files are not excluded one by one.
120
- if !@options[:auto_gen_only_exclude] || @files_with_offenses[cop_name].size > @exclude_limit
119
+ max_set_in_user_config =
120
+ @config_for_pwd.for_cop(cop_name)['Max'] != default_config(cop_name)['Max']
121
+ if !max_set_in_user_config &&
122
+ # In case auto_gen_only_exclude is set, only modify the maximum if the files are not
123
+ # excluded one by one.
124
+ (!@options[:auto_gen_only_exclude] ||
125
+ @files_with_offenses[cop_name].size > @exclude_limit)
121
126
  cfg.merge!(cfg[:exclude_limit])
122
127
  end
123
128
 
@@ -192,8 +197,8 @@ module RuboCop
192
197
  # 'Enabled' option will be put into file only if exclude
193
198
  # limit is exceeded.
194
199
  rejected_keys = ['Enabled']
195
- rejected_keys << 'EnforcedStyle' unless auto_gen_enforced_style?
196
- cfg.reject { |key| rejected_keys.include?(key) }
200
+ rejected_keys << /\AEnforcedStyle\w*/ unless auto_gen_enforced_style?
201
+ cfg.reject { |key| include_or_match?(rejected_keys, key) }
197
202
  end
198
203
 
199
204
  def output_offending_files(output_buffer, cfg, cop_name)
@@ -262,6 +267,12 @@ module RuboCop
262
267
  def no_exclude_limit?
263
268
  @options[:no_exclude_limit] == false
264
269
  end
270
+
271
+ # Returns true if the given arr include the given elm or if any of the
272
+ # given arr is a regexp that matches the given elm.
273
+ def include_or_match?(arr, elm)
274
+ arr.include?(elm) || arr.any? { |x| x.is_a?(Regexp) && x.match?(elm) }
275
+ end
265
276
  end
266
277
  end
267
278
  end
@@ -1,7 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'json'
4
- require 'pathname'
5
4
 
6
5
  module RuboCop
7
6
  module Formatter
@@ -14,7 +14,7 @@ module RuboCop
14
14
  require_relative 'formatter/emacs_style_formatter'
15
15
  require_relative 'formatter/file_list_formatter'
16
16
  require_relative 'formatter/fuubar_style_formatter'
17
- require_relative 'formatter/git_hub_actions_formatter'
17
+ require_relative 'formatter/github_actions_formatter'
18
18
  require_relative 'formatter/html_formatter'
19
19
  require_relative 'formatter/json_formatter'
20
20
  require_relative 'formatter/junit_formatter'
@@ -17,7 +17,7 @@ module RuboCop
17
17
  # @api private
18
18
  class Routes
19
19
  def self.handle(name, &block)
20
- define_method("handle_#{name}", &block)
20
+ define_method(:"handle_#{name}", &block)
21
21
  end
22
22
 
23
23
  private_class_method :handle
@@ -364,10 +364,6 @@ module RuboCop
364
364
  raise OptionArgumentError, '-C/--cache argument must be true or false'
365
365
  end
366
366
 
367
- if display_only_fail_level_offenses_with_autocorrect?
368
- raise OptionArgumentError, '--autocorrect cannot be used with ' \
369
- '--display-only-fail-level-offenses.'
370
- end
371
367
  validate_auto_gen_config
372
368
  validate_autocorrect
373
369
  validate_display_only_failed
@@ -460,10 +456,6 @@ module RuboCop
460
456
  (@options[:only] & %w[Lint/RedundantCopDisableDirective RedundantCopDisableDirective]).any?
461
457
  end
462
458
 
463
- def display_only_fail_level_offenses_with_autocorrect?
464
- @options.key?(:display_only_fail_level_offenses) && @options.key?(:autocorrect)
465
- end
466
-
467
459
  def except_syntax?
468
460
  @options.key?(:except) && (@options[:except] & %w[Lint/Syntax Syntax]).any?
469
461
  end
@@ -128,6 +128,12 @@ RSpec.shared_context 'mock console output' do
128
128
  end
129
129
  end
130
130
 
131
+ RSpec.shared_context 'lsp mode' do
132
+ before do
133
+ allow(cop).to receive(:lsp_mode?).and_return(true)
134
+ end
135
+ end
136
+
131
137
  RSpec.shared_context 'ruby 2.0' do
132
138
  let(:ruby_version) { 2.0 }
133
139
  end
@@ -13,6 +13,7 @@ RSpec.configure do |config|
13
13
  config.include HostEnvironmentSimulatorHelper
14
14
  config.include_context 'config', :config
15
15
  config.include_context 'isolated environment', :isolated_environment
16
+ config.include_context 'lsp mode', :lsp_mode
16
17
  config.include_context 'maintain registry', :restore_registry
17
18
  config.include_context 'ruby 2.0', :ruby20
18
19
  config.include_context 'ruby 2.1', :ruby21
@@ -1,6 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'fileutils'
4
3
  require 'pathname'
5
4
  require_relative '../cache_config'
6
5
  require_relative '../config_finder'
@@ -117,7 +116,7 @@ module RuboCop
117
116
 
118
117
  def pid_running?
119
118
  Process.kill(0, pid_path.read.to_i) == 1
120
- rescue Errno::ESRCH, Errno::ENOENT, Errno::EACCES
119
+ rescue Errno::ESRCH, Errno::ENOENT, Errno::EACCES, Errno::EROFS
121
120
  false
122
121
  end
123
122
 
@@ -17,7 +17,6 @@ module RuboCop
17
17
  class Exec < Base
18
18
  def run
19
19
  ensure_server!
20
- Cache.status_path.delete if Cache.status_path.file?
21
20
  read_stdin = ARGV.include?('-s') || ARGV.include?('--stdin')
22
21
  send_request(
23
22
  command: 'exec',
@@ -16,7 +16,6 @@ module RuboCop
16
16
  # @api private
17
17
  class Exec < Base
18
18
  def run
19
- Cache.status_path.delete if Cache.status_path.file?
20
19
  # RuboCop output is colorized by default where there is a TTY.
21
20
  # We must pass the --color option to preserve this behavior.
22
21
  @args.unshift('--color') unless %w[--color --no-color].any? { |f| @args.include?(f) }
@@ -3,7 +3,7 @@
3
3
  module RuboCop
4
4
  # This module holds the RuboCop version information.
5
5
  module Version
6
- STRING = '1.59.0'
6
+ STRING = '1.60.2'
7
7
 
8
8
  MSG = '%<version>s (using Parser %<parser_version>s, ' \
9
9
  'rubocop-ast %<rubocop_ast_version>s, ' \
metadata CHANGED
@@ -1,16 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubocop
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.59.0
4
+ version: 1.60.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bozhidar Batsov
8
8
  - Jonas Arvidsson
9
9
  - Yuji Nakayama
10
- autorequire:
10
+ autorequire:
11
11
  bindir: exe
12
12
  cert_chain: []
13
- date: 2023-12-11 00:00:00.000000000 Z
13
+ date: 2024-01-24 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: json
@@ -60,14 +60,14 @@ dependencies:
60
60
  requirements:
61
61
  - - ">="
62
62
  - !ruby/object:Gem::Version
63
- version: 3.2.2.4
63
+ version: 3.3.0.2
64
64
  type: :runtime
65
65
  prerelease: false
66
66
  version_requirements: !ruby/object:Gem::Requirement
67
67
  requirements:
68
68
  - - ">="
69
69
  - !ruby/object:Gem::Version
70
- version: 3.2.2.4
70
+ version: 3.3.0.2
71
71
  - !ruby/object:Gem::Dependency
72
72
  name: rainbow
73
73
  requirement: !ruby/object:Gem::Requirement
@@ -964,7 +964,7 @@ files:
964
964
  - lib/rubocop/formatter/file_list_formatter.rb
965
965
  - lib/rubocop/formatter/formatter_set.rb
966
966
  - lib/rubocop/formatter/fuubar_style_formatter.rb
967
- - lib/rubocop/formatter/git_hub_actions_formatter.rb
967
+ - lib/rubocop/formatter/github_actions_formatter.rb
968
968
  - lib/rubocop/formatter/html_formatter.rb
969
969
  - lib/rubocop/formatter/json_formatter.rb
970
970
  - lib/rubocop/formatter/junit_formatter.rb
@@ -1028,12 +1028,12 @@ licenses:
1028
1028
  - MIT
1029
1029
  metadata:
1030
1030
  homepage_uri: https://rubocop.org/
1031
- changelog_uri: https://github.com/rubocop/rubocop/blob/master/CHANGELOG.md
1031
+ changelog_uri: https://github.com/rubocop/rubocop/releases/tag/v1.60.2
1032
1032
  source_code_uri: https://github.com/rubocop/rubocop/
1033
- documentation_uri: https://docs.rubocop.org/rubocop/1.59/
1033
+ documentation_uri: https://docs.rubocop.org/rubocop/1.60/
1034
1034
  bug_tracker_uri: https://github.com/rubocop/rubocop/issues
1035
1035
  rubygems_mfa_required: 'true'
1036
- post_install_message:
1036
+ post_install_message:
1037
1037
  rdoc_options: []
1038
1038
  require_paths:
1039
1039
  - lib
@@ -1048,8 +1048,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
1048
1048
  - !ruby/object:Gem::Version
1049
1049
  version: '0'
1050
1050
  requirements: []
1051
- rubygems_version: 3.3.7
1052
- signing_key:
1051
+ rubygems_version: 3.4.22
1052
+ signing_key:
1053
1053
  specification_version: 4
1054
1054
  summary: Automatic Ruby code style checking tool.
1055
1055
  test_files: []