rubocop 1.41.0 → 1.42.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 (60) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE.txt +1 -1
  3. data/README.md +2 -2
  4. data/config/default.yml +26 -1
  5. data/lib/rubocop/cli.rb +1 -1
  6. data/lib/rubocop/config.rb +7 -7
  7. data/lib/rubocop/config_loader_resolver.rb +5 -1
  8. data/lib/rubocop/cop/base.rb +62 -61
  9. data/lib/rubocop/cop/cop.rb +28 -28
  10. data/lib/rubocop/cop/corrector.rb +23 -11
  11. data/lib/rubocop/cop/gemspec/dependency_version.rb +16 -18
  12. data/lib/rubocop/cop/layout/class_structure.rb +32 -11
  13. data/lib/rubocop/cop/layout/comment_indentation.rb +3 -1
  14. data/lib/rubocop/cop/layout/indentation_style.rb +4 -1
  15. data/lib/rubocop/cop/layout/line_continuation_spacing.rb +6 -6
  16. data/lib/rubocop/cop/layout/multiline_block_layout.rb +1 -1
  17. data/lib/rubocop/cop/layout/space_around_keyword.rb +1 -1
  18. data/lib/rubocop/cop/layout/trailing_whitespace.rb +5 -2
  19. data/lib/rubocop/cop/lint/out_of_range_regexp_ref.rb +19 -0
  20. data/lib/rubocop/cop/lint/redundant_cop_disable_directive.rb +3 -1
  21. data/lib/rubocop/cop/lint/regexp_as_condition.rb +6 -0
  22. data/lib/rubocop/cop/lint/require_parentheses.rb +3 -1
  23. data/lib/rubocop/cop/lint/unused_method_argument.rb +2 -1
  24. data/lib/rubocop/cop/lint/useless_ruby2_keywords.rb +5 -3
  25. data/lib/rubocop/cop/metrics/perceived_complexity.rb +1 -1
  26. data/lib/rubocop/cop/metrics/utils/abc_size_calculator.rb +4 -4
  27. data/lib/rubocop/cop/mixin/annotation_comment.rb +1 -1
  28. data/lib/rubocop/cop/mixin/preceding_following_alignment.rb +1 -1
  29. data/lib/rubocop/cop/naming/block_forwarding.rb +1 -1
  30. data/lib/rubocop/cop/registry.rb +22 -22
  31. data/lib/rubocop/cop/security/compound_hash.rb +2 -1
  32. data/lib/rubocop/cop/style/alias.rb +9 -1
  33. data/lib/rubocop/cop/style/block_comments.rb +1 -1
  34. data/lib/rubocop/cop/style/concat_array_literals.rb +22 -2
  35. data/lib/rubocop/cop/style/documentation.rb +10 -4
  36. data/lib/rubocop/cop/style/guard_clause.rb +12 -8
  37. data/lib/rubocop/cop/style/hash_syntax.rb +10 -7
  38. data/lib/rubocop/cop/style/identical_conditional_branches.rb +15 -0
  39. data/lib/rubocop/cop/style/map_to_set.rb +61 -0
  40. data/lib/rubocop/cop/style/method_def_parentheses.rb +11 -4
  41. data/lib/rubocop/cop/style/min_max_comparison.rb +73 -0
  42. data/lib/rubocop/cop/style/redundant_string_escape.rb +6 -3
  43. data/lib/rubocop/cop/style/require_order.rb +4 -2
  44. data/lib/rubocop/cop/style/select_by_regexp.rb +6 -2
  45. data/lib/rubocop/cop/style/signal_exception.rb +8 -6
  46. data/lib/rubocop/cop/style/trailing_comma_in_arguments.rb +4 -4
  47. data/lib/rubocop/cop/style/word_array.rb +41 -0
  48. data/lib/rubocop/cop/style/yoda_expression.rb +74 -0
  49. data/lib/rubocop/cop/style/zero_length_predicate.rb +31 -14
  50. data/lib/rubocop/cop/team.rb +29 -29
  51. data/lib/rubocop/cop/variable_force.rb +0 -3
  52. data/lib/rubocop/cops_documentation_generator.rb +11 -8
  53. data/lib/rubocop/formatter.rb +2 -0
  54. data/lib/rubocop/path_util.rb +6 -1
  55. data/lib/rubocop/result_cache.rb +1 -1
  56. data/lib/rubocop/runner.rb +10 -3
  57. data/lib/rubocop/target_ruby.rb +0 -1
  58. data/lib/rubocop/version.rb +1 -1
  59. data/lib/rubocop.rb +3 -0
  60. metadata +12 -9
@@ -27,6 +27,11 @@ module RuboCop
27
27
  # @api private
28
28
  MAX_ITERATIONS = 200
29
29
 
30
+ # @api private
31
+ REDUNDANT_COP_DISABLE_DIRECTIVE_RULES = %w[
32
+ Lint/RedundantCopDisableDirective RedundantCopDisableDirective Lint
33
+ ].freeze
34
+
30
35
  attr_reader :errors, :warnings
31
36
  attr_writer :aborting
32
37
 
@@ -194,7 +199,9 @@ module RuboCop
194
199
  end
195
200
 
196
201
  def check_for_redundant_disables?(source)
197
- !source.disabled_line_ranges.empty? && !filtered_run?
202
+ return false if source.disabled_line_ranges.empty? || except_redundant_cop_disable_directive?
203
+
204
+ !@options[:only]
198
205
  end
199
206
 
200
207
  def redundant_cop_disable_directive(file)
@@ -205,8 +212,8 @@ module RuboCop
205
212
  yield cop if cop.relevant_file?(file)
206
213
  end
207
214
 
208
- def filtered_run?
209
- @options[:except] || @options[:only]
215
+ def except_redundant_cop_disable_directive?
216
+ @options[:except] && (@options[:except] & REDUNDANT_COP_DISABLE_DIRECTIVE_RULES).any?
210
217
  end
211
218
 
212
219
  def file_started(file)
@@ -244,7 +244,6 @@ module RuboCop
244
244
  ].freeze
245
245
 
246
246
  private_constant :SOURCES
247
-
248
247
  def initialize(config)
249
248
  @config = config
250
249
  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.41.0'
6
+ STRING = '1.42.0'
7
7
 
8
8
  MSG = '%<version>s (using Parser %<parser_version>s, ' \
9
9
  'rubocop-ast %<rubocop_ast_version>s, ' \
data/lib/rubocop.rb CHANGED
@@ -538,8 +538,10 @@ require_relative 'rubocop/cop/style/lambda_call'
538
538
  require_relative 'rubocop/cop/style/line_end_concatenation'
539
539
  require_relative 'rubocop/cop/style/magic_comment_format'
540
540
  require_relative 'rubocop/cop/style/map_to_hash'
541
+ require_relative 'rubocop/cop/style/map_to_set'
541
542
  require_relative 'rubocop/cop/style/method_call_without_args_parentheses'
542
543
  require_relative 'rubocop/cop/style/method_call_with_args_parentheses'
544
+ require_relative 'rubocop/cop/style/min_max_comparison'
543
545
  require_relative 'rubocop/cop/style/multiline_in_pattern_then'
544
546
  require_relative 'rubocop/cop/style/numbered_parameters'
545
547
  require_relative 'rubocop/cop/style/open_struct_use'
@@ -675,6 +677,7 @@ require_relative 'rubocop/cop/style/while_until_do'
675
677
  require_relative 'rubocop/cop/style/while_until_modifier'
676
678
  require_relative 'rubocop/cop/style/word_array'
677
679
  require_relative 'rubocop/cop/style/yoda_condition'
680
+ require_relative 'rubocop/cop/style/yoda_expression'
678
681
  require_relative 'rubocop/cop/style/zero_length_predicate'
679
682
 
680
683
  require_relative 'rubocop/cop/security/compound_hash'
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.41.0
4
+ version: 1.42.0
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: 2022-12-20 00:00:00.000000000 Z
13
+ date: 2023-01-01 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: json
@@ -120,7 +120,7 @@ dependencies:
120
120
  requirements:
121
121
  - - ">="
122
122
  - !ruby/object:Gem::Version
123
- version: 1.23.0
123
+ version: 1.24.1
124
124
  - - "<"
125
125
  - !ruby/object:Gem::Version
126
126
  version: '2.0'
@@ -130,7 +130,7 @@ dependencies:
130
130
  requirements:
131
131
  - - ">="
132
132
  - !ruby/object:Gem::Version
133
- version: 1.23.0
133
+ version: 1.24.1
134
134
  - - "<"
135
135
  - !ruby/object:Gem::Version
136
136
  version: '2.0'
@@ -760,6 +760,7 @@ files:
760
760
  - lib/rubocop/cop/style/magic_comment_format.rb
761
761
  - lib/rubocop/cop/style/map_compact_with_conditional_block.rb
762
762
  - lib/rubocop/cop/style/map_to_hash.rb
763
+ - lib/rubocop/cop/style/map_to_set.rb
763
764
  - lib/rubocop/cop/style/method_call_with_args_parentheses.rb
764
765
  - lib/rubocop/cop/style/method_call_with_args_parentheses/omit_parentheses.rb
765
766
  - lib/rubocop/cop/style/method_call_with_args_parentheses/require_parentheses.rb
@@ -767,6 +768,7 @@ files:
767
768
  - lib/rubocop/cop/style/method_called_on_do_end_block.rb
768
769
  - lib/rubocop/cop/style/method_def_parentheses.rb
769
770
  - lib/rubocop/cop/style/min_max.rb
771
+ - lib/rubocop/cop/style/min_max_comparison.rb
770
772
  - lib/rubocop/cop/style/missing_else.rb
771
773
  - lib/rubocop/cop/style/missing_respond_to_missing.rb
772
774
  - lib/rubocop/cop/style/mixin_grouping.rb
@@ -898,6 +900,7 @@ files:
898
900
  - lib/rubocop/cop/style/while_until_modifier.rb
899
901
  - lib/rubocop/cop/style/word_array.rb
900
902
  - lib/rubocop/cop/style/yoda_condition.rb
903
+ - lib/rubocop/cop/style/yoda_expression.rb
901
904
  - lib/rubocop/cop/style/zero_length_predicate.rb
902
905
  - lib/rubocop/cop/team.rb
903
906
  - lib/rubocop/cop/util.rb
@@ -992,10 +995,10 @@ metadata:
992
995
  homepage_uri: https://rubocop.org/
993
996
  changelog_uri: https://github.com/rubocop/rubocop/blob/master/CHANGELOG.md
994
997
  source_code_uri: https://github.com/rubocop/rubocop/
995
- documentation_uri: https://docs.rubocop.org/rubocop/1.41/
998
+ documentation_uri: https://docs.rubocop.org/rubocop/1.42/
996
999
  bug_tracker_uri: https://github.com/rubocop/rubocop/issues
997
1000
  rubygems_mfa_required: 'true'
998
- post_install_message:
1001
+ post_install_message:
999
1002
  rdoc_options: []
1000
1003
  require_paths:
1001
1004
  - lib
@@ -1010,8 +1013,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
1010
1013
  - !ruby/object:Gem::Version
1011
1014
  version: '0'
1012
1015
  requirements: []
1013
- rubygems_version: 3.1.2
1014
- signing_key:
1016
+ rubygems_version: 3.3.7
1017
+ signing_key:
1015
1018
  specification_version: 4
1016
1019
  summary: Automatic Ruby code style checking tool.
1017
1020
  test_files: []