rubocop 1.40.0 → 1.43.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (123) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE.txt +1 -1
  3. data/README.md +2 -2
  4. data/config/default.yml +52 -2
  5. data/lib/rubocop/cli.rb +1 -1
  6. data/lib/rubocop/config.rb +34 -11
  7. data/lib/rubocop/config_loader.rb +9 -0
  8. data/lib/rubocop/config_loader_resolver.rb +5 -1
  9. data/lib/rubocop/config_validator.rb +1 -1
  10. data/lib/rubocop/cop/badge.rb +9 -4
  11. data/lib/rubocop/cop/base.rb +83 -66
  12. data/lib/rubocop/cop/commissioner.rb +8 -3
  13. data/lib/rubocop/cop/cop.rb +29 -29
  14. data/lib/rubocop/cop/corrector.rb +23 -11
  15. data/lib/rubocop/cop/gemspec/dependency_version.rb +16 -18
  16. data/lib/rubocop/cop/internal_affairs/cop_description.rb +3 -1
  17. data/lib/rubocop/cop/layout/class_structure.rb +32 -11
  18. data/lib/rubocop/cop/layout/comment_indentation.rb +3 -1
  19. data/lib/rubocop/cop/layout/empty_lines.rb +2 -0
  20. data/lib/rubocop/cop/layout/extra_spacing.rb +10 -6
  21. data/lib/rubocop/cop/layout/first_array_element_line_break.rb +38 -2
  22. data/lib/rubocop/cop/layout/first_hash_element_line_break.rb +49 -2
  23. data/lib/rubocop/cop/layout/first_method_argument_line_break.rb +61 -2
  24. data/lib/rubocop/cop/layout/first_method_parameter_line_break.rb +52 -2
  25. data/lib/rubocop/cop/layout/indentation_style.rb +7 -2
  26. data/lib/rubocop/cop/layout/line_continuation_leading_space.rb +5 -0
  27. data/lib/rubocop/cop/layout/line_continuation_spacing.rb +11 -5
  28. data/lib/rubocop/cop/layout/line_length.rb +2 -0
  29. data/lib/rubocop/cop/layout/multiline_array_line_breaks.rb +51 -2
  30. data/lib/rubocop/cop/layout/multiline_block_layout.rb +1 -1
  31. data/lib/rubocop/cop/layout/multiline_hash_key_line_breaks.rb +49 -2
  32. data/lib/rubocop/cop/layout/multiline_method_argument_line_breaks.rb +53 -2
  33. data/lib/rubocop/cop/layout/multiline_method_parameter_line_breaks.rb +58 -2
  34. data/lib/rubocop/cop/layout/redundant_line_break.rb +2 -2
  35. data/lib/rubocop/cop/layout/space_around_keyword.rb +1 -1
  36. data/lib/rubocop/cop/layout/trailing_empty_lines.rb +1 -1
  37. data/lib/rubocop/cop/layout/trailing_whitespace.rb +11 -4
  38. data/lib/rubocop/cop/lint/constant_resolution.rb +4 -0
  39. data/lib/rubocop/cop/lint/debugger.rb +3 -1
  40. data/lib/rubocop/cop/lint/duplicate_branch.rb +0 -2
  41. data/lib/rubocop/cop/lint/duplicate_methods.rb +19 -8
  42. data/lib/rubocop/cop/lint/non_atomic_file_operation.rb +10 -5
  43. data/lib/rubocop/cop/lint/out_of_range_regexp_ref.rb +19 -0
  44. data/lib/rubocop/cop/lint/redundant_cop_disable_directive.rb +3 -1
  45. data/lib/rubocop/cop/lint/redundant_cop_enable_directive.rb +1 -1
  46. data/lib/rubocop/cop/lint/regexp_as_condition.rb +6 -0
  47. data/lib/rubocop/cop/lint/require_parentheses.rb +3 -1
  48. data/lib/rubocop/cop/lint/safe_navigation_chain.rb +8 -19
  49. data/lib/rubocop/cop/lint/unused_method_argument.rb +2 -1
  50. data/lib/rubocop/cop/lint/useless_rescue.rb +71 -0
  51. data/lib/rubocop/cop/lint/useless_ruby2_keywords.rb +5 -3
  52. data/lib/rubocop/cop/metrics/class_length.rb +1 -1
  53. data/lib/rubocop/cop/metrics/module_length.rb +1 -1
  54. data/lib/rubocop/cop/metrics/parameter_lists.rb +27 -0
  55. data/lib/rubocop/cop/metrics/perceived_complexity.rb +1 -1
  56. data/lib/rubocop/cop/metrics/utils/abc_size_calculator.rb +4 -4
  57. data/lib/rubocop/cop/metrics/utils/code_length_calculator.rb +2 -2
  58. data/lib/rubocop/cop/mixin/alignment.rb +1 -1
  59. data/lib/rubocop/cop/mixin/allowed_identifiers.rb +2 -2
  60. data/lib/rubocop/cop/mixin/annotation_comment.rb +13 -6
  61. data/lib/rubocop/cop/mixin/configurable_enforced_style.rb +21 -9
  62. data/lib/rubocop/cop/mixin/first_element_line_break.rb +11 -7
  63. data/lib/rubocop/cop/mixin/hash_shorthand_syntax.rb +14 -2
  64. data/lib/rubocop/cop/mixin/line_length_help.rb +8 -1
  65. data/lib/rubocop/cop/mixin/method_complexity.rb +5 -3
  66. data/lib/rubocop/cop/mixin/multiline_element_line_breaks.rb +5 -3
  67. data/lib/rubocop/cop/mixin/percent_array.rb +3 -5
  68. data/lib/rubocop/cop/mixin/preceding_following_alignment.rb +1 -1
  69. data/lib/rubocop/cop/mixin/require_library.rb +2 -0
  70. data/lib/rubocop/cop/mixin/rescue_node.rb +3 -3
  71. data/lib/rubocop/cop/mixin/statement_modifier.rb +2 -1
  72. data/lib/rubocop/cop/naming/block_forwarding.rb +1 -1
  73. data/lib/rubocop/cop/naming/class_and_module_camel_case.rb +2 -0
  74. data/lib/rubocop/cop/naming/inclusive_language.rb +4 -1
  75. data/lib/rubocop/cop/registry.rb +28 -25
  76. data/lib/rubocop/cop/security/compound_hash.rb +2 -1
  77. data/lib/rubocop/cop/style/alias.rb +9 -1
  78. data/lib/rubocop/cop/style/block_comments.rb +1 -1
  79. data/lib/rubocop/cop/style/concat_array_literals.rb +86 -0
  80. data/lib/rubocop/cop/style/documentation.rb +11 -5
  81. data/lib/rubocop/cop/style/guard_clause.rb +17 -9
  82. data/lib/rubocop/cop/style/hash_each_methods.rb +13 -1
  83. data/lib/rubocop/cop/style/hash_syntax.rb +11 -7
  84. data/lib/rubocop/cop/style/identical_conditional_branches.rb +15 -0
  85. data/lib/rubocop/cop/style/if_with_semicolon.rb +2 -3
  86. data/lib/rubocop/cop/style/inverse_methods.rb +2 -0
  87. data/lib/rubocop/cop/style/line_end_concatenation.rb +4 -1
  88. data/lib/rubocop/cop/style/map_to_set.rb +61 -0
  89. data/lib/rubocop/cop/style/method_call_with_args_parentheses/omit_parentheses.rb +12 -9
  90. data/lib/rubocop/cop/style/method_def_parentheses.rb +11 -4
  91. data/lib/rubocop/cop/style/min_max_comparison.rb +73 -0
  92. data/lib/rubocop/cop/style/missing_else.rb +13 -1
  93. data/lib/rubocop/cop/style/operator_method_call.rb +15 -1
  94. data/lib/rubocop/cop/style/redundant_constant_base.rb +13 -0
  95. data/lib/rubocop/cop/style/redundant_double_splat_hash_braces.rb +39 -0
  96. data/lib/rubocop/cop/style/redundant_regexp_escape.rb +2 -1
  97. data/lib/rubocop/cop/style/redundant_string_escape.rb +6 -3
  98. data/lib/rubocop/cop/style/require_order.rb +63 -9
  99. data/lib/rubocop/cop/style/select_by_regexp.rb +6 -2
  100. data/lib/rubocop/cop/style/semicolon.rb +2 -1
  101. data/lib/rubocop/cop/style/signal_exception.rb +8 -6
  102. data/lib/rubocop/cop/style/string_hash_keys.rb +4 -1
  103. data/lib/rubocop/cop/style/trailing_comma_in_arguments.rb +4 -4
  104. data/lib/rubocop/cop/style/word_array.rb +41 -0
  105. data/lib/rubocop/cop/style/yoda_expression.rb +81 -0
  106. data/lib/rubocop/cop/style/zero_length_predicate.rb +31 -14
  107. data/lib/rubocop/cop/team.rb +29 -29
  108. data/lib/rubocop/cop/util.rb +31 -4
  109. data/lib/rubocop/cop/variable_force.rb +0 -3
  110. data/lib/rubocop/cops_documentation_generator.rb +33 -11
  111. data/lib/rubocop/directive_comment.rb +1 -1
  112. data/lib/rubocop/file_patterns.rb +43 -0
  113. data/lib/rubocop/formatter.rb +2 -0
  114. data/lib/rubocop/options.rb +1 -1
  115. data/lib/rubocop/path_util.rb +38 -22
  116. data/lib/rubocop/result_cache.rb +1 -1
  117. data/lib/rubocop/runner.rb +10 -3
  118. data/lib/rubocop/target_finder.rb +1 -1
  119. data/lib/rubocop/target_ruby.rb +0 -1
  120. data/lib/rubocop/version.rb +1 -1
  121. data/lib/rubocop.rb +7 -1
  122. metadata +16 -10
  123. data/lib/rubocop/optimized_patterns.rb +0 -38
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.40.0
4
+ version: 1.43.0
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: 2022-12-08 00:00:00.000000000 Z
13
+ date: 2023-01-10 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: json
@@ -46,14 +46,14 @@ dependencies:
46
46
  requirements:
47
47
  - - ">="
48
48
  - !ruby/object:Gem::Version
49
- version: 3.1.2.1
49
+ version: 3.2.0.0
50
50
  type: :runtime
51
51
  prerelease: false
52
52
  version_requirements: !ruby/object:Gem::Requirement
53
53
  requirements:
54
54
  - - ">="
55
55
  - !ruby/object:Gem::Version
56
- version: 3.1.2.1
56
+ version: 3.2.0.0
57
57
  - !ruby/object:Gem::Dependency
58
58
  name: rainbow
59
59
  requirement: !ruby/object:Gem::Requirement
@@ -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'
@@ -154,7 +154,7 @@ dependencies:
154
154
  requirements:
155
155
  - - ">="
156
156
  - !ruby/object:Gem::Version
157
- version: 1.4.0
157
+ version: 2.4.0
158
158
  - - "<"
159
159
  - !ruby/object:Gem::Version
160
160
  version: '3.0'
@@ -164,7 +164,7 @@ dependencies:
164
164
  requirements:
165
165
  - - ">="
166
166
  - !ruby/object:Gem::Version
167
- version: 1.4.0
167
+ version: 2.4.0
168
168
  - - "<"
169
169
  - !ruby/object:Gem::Version
170
170
  version: '3.0'
@@ -539,6 +539,7 @@ files:
539
539
  - lib/rubocop/cop/lint/useless_assignment.rb
540
540
  - lib/rubocop/cop/lint/useless_else_without_rescue.rb
541
541
  - lib/rubocop/cop/lint/useless_method_definition.rb
542
+ - lib/rubocop/cop/lint/useless_rescue.rb
542
543
  - lib/rubocop/cop/lint/useless_ruby2_keywords.rb
543
544
  - lib/rubocop/cop/lint/useless_setter_call.rb
544
545
  - lib/rubocop/cop/lint/useless_times.rb
@@ -691,6 +692,7 @@ files:
691
692
  - lib/rubocop/cop/style/command_literal.rb
692
693
  - lib/rubocop/cop/style/comment_annotation.rb
693
694
  - lib/rubocop/cop/style/commented_keyword.rb
695
+ - lib/rubocop/cop/style/concat_array_literals.rb
694
696
  - lib/rubocop/cop/style/conditional_assignment.rb
695
697
  - lib/rubocop/cop/style/constant_visibility.rb
696
698
  - lib/rubocop/cop/style/copyright.rb
@@ -759,6 +761,7 @@ files:
759
761
  - lib/rubocop/cop/style/magic_comment_format.rb
760
762
  - lib/rubocop/cop/style/map_compact_with_conditional_block.rb
761
763
  - lib/rubocop/cop/style/map_to_hash.rb
764
+ - lib/rubocop/cop/style/map_to_set.rb
762
765
  - lib/rubocop/cop/style/method_call_with_args_parentheses.rb
763
766
  - lib/rubocop/cop/style/method_call_with_args_parentheses/omit_parentheses.rb
764
767
  - lib/rubocop/cop/style/method_call_with_args_parentheses/require_parentheses.rb
@@ -766,6 +769,7 @@ files:
766
769
  - lib/rubocop/cop/style/method_called_on_do_end_block.rb
767
770
  - lib/rubocop/cop/style/method_def_parentheses.rb
768
771
  - lib/rubocop/cop/style/min_max.rb
772
+ - lib/rubocop/cop/style/min_max_comparison.rb
769
773
  - lib/rubocop/cop/style/missing_else.rb
770
774
  - lib/rubocop/cop/style/missing_respond_to_missing.rb
771
775
  - lib/rubocop/cop/style/mixin_grouping.rb
@@ -824,6 +828,7 @@ files:
824
828
  - lib/rubocop/cop/style/redundant_condition.rb
825
829
  - lib/rubocop/cop/style/redundant_conditional.rb
826
830
  - lib/rubocop/cop/style/redundant_constant_base.rb
831
+ - lib/rubocop/cop/style/redundant_double_splat_hash_braces.rb
827
832
  - lib/rubocop/cop/style/redundant_each.rb
828
833
  - lib/rubocop/cop/style/redundant_exception.rb
829
834
  - lib/rubocop/cop/style/redundant_fetch_block.rb
@@ -896,6 +901,7 @@ files:
896
901
  - lib/rubocop/cop/style/while_until_modifier.rb
897
902
  - lib/rubocop/cop/style/word_array.rb
898
903
  - lib/rubocop/cop/style/yoda_condition.rb
904
+ - lib/rubocop/cop/style/yoda_expression.rb
899
905
  - lib/rubocop/cop/style/zero_length_predicate.rb
900
906
  - lib/rubocop/cop/team.rb
901
907
  - lib/rubocop/cop/util.rb
@@ -918,6 +924,7 @@ files:
918
924
  - lib/rubocop/ext/regexp_parser.rb
919
925
  - lib/rubocop/feature_loader.rb
920
926
  - lib/rubocop/file_finder.rb
927
+ - lib/rubocop/file_patterns.rb
921
928
  - lib/rubocop/formatter.rb
922
929
  - lib/rubocop/formatter/auto_gen_config_formatter.rb
923
930
  - lib/rubocop/formatter/base_formatter.rb
@@ -944,7 +951,6 @@ files:
944
951
  - lib/rubocop/lockfile.rb
945
952
  - lib/rubocop/magic_comment.rb
946
953
  - lib/rubocop/name_similarity.rb
947
- - lib/rubocop/optimized_patterns.rb
948
954
  - lib/rubocop/options.rb
949
955
  - lib/rubocop/path_util.rb
950
956
  - lib/rubocop/platform.rb
@@ -990,7 +996,7 @@ metadata:
990
996
  homepage_uri: https://rubocop.org/
991
997
  changelog_uri: https://github.com/rubocop/rubocop/blob/master/CHANGELOG.md
992
998
  source_code_uri: https://github.com/rubocop/rubocop/
993
- documentation_uri: https://docs.rubocop.org/rubocop/1.40/
999
+ documentation_uri: https://docs.rubocop.org/rubocop/1.43/
994
1000
  bug_tracker_uri: https://github.com/rubocop/rubocop/issues
995
1001
  rubygems_mfa_required: 'true'
996
1002
  post_install_message:
@@ -1,38 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module RuboCop
4
- # @api private
5
- module OptimizedPatterns
6
- # A wrapper around patterns array to perform optimized search.
7
- # @api private
8
- class PatternsSet
9
- def initialize(patterns)
10
- @strings = Set.new
11
- @patterns = []
12
- partition_patterns(patterns)
13
- end
14
-
15
- def match?(path)
16
- @strings.include?(path) || @patterns.any? { |pattern| PathUtil.match_path?(pattern, path) }
17
- end
18
-
19
- private
20
-
21
- def partition_patterns(patterns)
22
- patterns.each do |pattern|
23
- if pattern.is_a?(String) && !pattern.match?(/[*{\[?]/)
24
- @strings << pattern
25
- else
26
- @patterns << pattern
27
- end
28
- end
29
- end
30
- end
31
-
32
- @cache = {}.compare_by_identity
33
-
34
- def self.from(patterns)
35
- @cache[patterns] ||= PatternsSet.new(patterns)
36
- end
37
- end
38
- end