rubocop 1.38.0 → 1.40.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 (83) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/config/default.yml +51 -11
  4. data/exe/rubocop +1 -1
  5. data/lib/rubocop/comment_config.rb +5 -0
  6. data/lib/rubocop/config.rb +5 -4
  7. data/lib/rubocop/config_loader.rb +5 -5
  8. data/lib/rubocop/config_loader_resolver.rb +1 -1
  9. data/lib/rubocop/cop/base.rb +2 -9
  10. data/lib/rubocop/cop/correctors/multiline_literal_brace_corrector.rb +22 -6
  11. data/lib/rubocop/cop/internal_affairs/lambda_or_proc.rb +46 -0
  12. data/lib/rubocop/cop/internal_affairs.rb +1 -0
  13. data/lib/rubocop/cop/layout/line_continuation_leading_space.rb +29 -8
  14. data/lib/rubocop/cop/layout/space_inside_array_percent_literal.rb +3 -0
  15. data/lib/rubocop/cop/layout/space_inside_percent_literal_delimiters.rb +34 -0
  16. data/lib/rubocop/cop/lint/ambiguous_block_association.rb +1 -1
  17. data/lib/rubocop/cop/lint/assignment_in_condition.rb +11 -1
  18. data/lib/rubocop/cop/lint/deprecated_constants.rb +8 -1
  19. data/lib/rubocop/cop/lint/duplicate_methods.rb +17 -8
  20. data/lib/rubocop/cop/lint/empty_block.rb +1 -5
  21. data/lib/rubocop/cop/lint/empty_conditional_body.rb +1 -1
  22. data/lib/rubocop/cop/lint/interpolation_check.rb +4 -3
  23. data/lib/rubocop/cop/lint/parentheses_as_grouped_expression.rb +5 -0
  24. data/lib/rubocop/cop/lint/redundant_cop_disable_directive.rb +13 -3
  25. data/lib/rubocop/cop/lint/safe_navigation_chain.rb +15 -6
  26. data/lib/rubocop/cop/lint/send_with_mixin_argument.rb +5 -4
  27. data/lib/rubocop/cop/lint/shadowing_outer_local_variable.rb +4 -3
  28. data/lib/rubocop/cop/lint/suppressed_exception.rb +1 -1
  29. data/lib/rubocop/cop/lint/void.rb +6 -6
  30. data/lib/rubocop/cop/metrics/abc_size.rb +1 -1
  31. data/lib/rubocop/cop/metrics/block_length.rb +9 -4
  32. data/lib/rubocop/cop/metrics/class_length.rb +9 -4
  33. data/lib/rubocop/cop/metrics/method_length.rb +9 -4
  34. data/lib/rubocop/cop/metrics/module_length.rb +9 -4
  35. data/lib/rubocop/cop/metrics/utils/code_length_calculator.rb +5 -2
  36. data/lib/rubocop/cop/mixin/hash_shorthand_syntax.rb +24 -5
  37. data/lib/rubocop/cop/mixin/range_help.rb +23 -0
  38. data/lib/rubocop/cop/mixin/statement_modifier.rb +15 -1
  39. data/lib/rubocop/cop/mixin/visibility_help.rb +40 -5
  40. data/lib/rubocop/cop/registry.rb +23 -11
  41. data/lib/rubocop/cop/style/access_modifier_declarations.rb +1 -25
  42. data/lib/rubocop/cop/style/array_intersect.rb +111 -0
  43. data/lib/rubocop/cop/style/class_equality_comparison.rb +7 -5
  44. data/lib/rubocop/cop/style/collection_compact.rb +1 -1
  45. data/lib/rubocop/cop/style/guard_clause.rb +32 -5
  46. data/lib/rubocop/cop/style/hash_as_last_array_item.rb +1 -0
  47. data/lib/rubocop/cop/style/hash_each_methods.rb +32 -10
  48. data/lib/rubocop/cop/style/hash_except.rb +4 -0
  49. data/lib/rubocop/cop/style/if_with_semicolon.rb +2 -1
  50. data/lib/rubocop/cop/style/nil_lambda.rb +1 -1
  51. data/lib/rubocop/cop/style/object_then.rb +3 -0
  52. data/lib/rubocop/cop/style/operator_method_call.rb +13 -0
  53. data/lib/rubocop/cop/style/quoted_symbols.rb +1 -1
  54. data/lib/rubocop/cop/style/redundant_argument.rb +3 -0
  55. data/lib/rubocop/cop/style/redundant_constant_base.rb +72 -0
  56. data/lib/rubocop/cop/style/redundant_each.rb +13 -8
  57. data/lib/rubocop/cop/style/redundant_regexp_escape.rb +12 -3
  58. data/lib/rubocop/cop/style/redundant_return.rb +7 -0
  59. data/lib/rubocop/cop/style/redundant_sort.rb +1 -1
  60. data/lib/rubocop/cop/style/require_order.rb +88 -0
  61. data/lib/rubocop/cop/style/safe_navigation.rb +35 -6
  62. data/lib/rubocop/cop/style/select_by_regexp.rb +8 -4
  63. data/lib/rubocop/cop/style/string_literals.rb +1 -5
  64. data/lib/rubocop/cop/style/symbol_proc.rb +2 -4
  65. data/lib/rubocop/cop/team.rb +1 -1
  66. data/lib/rubocop/cop/util.rb +2 -2
  67. data/lib/rubocop/cop/variable_force/assignment.rb +1 -1
  68. data/lib/rubocop/cop/variable_force.rb +20 -29
  69. data/lib/rubocop/cops_documentation_generator.rb +3 -4
  70. data/lib/rubocop/formatter/disabled_config_formatter.rb +17 -6
  71. data/lib/rubocop/formatter/html_formatter.rb +1 -1
  72. data/lib/rubocop/formatter.rb +3 -1
  73. data/lib/rubocop/optimized_patterns.rb +38 -0
  74. data/lib/rubocop/options.rb +9 -1
  75. data/lib/rubocop/path_util.rb +14 -2
  76. data/lib/rubocop/result_cache.rb +1 -1
  77. data/lib/rubocop/rspec/cop_helper.rb +4 -1
  78. data/lib/rubocop/rspec/support.rb +2 -2
  79. data/lib/rubocop/server/core.rb +16 -1
  80. data/lib/rubocop/target_ruby.rb +1 -1
  81. data/lib/rubocop/version.rb +1 -1
  82. data/lib/rubocop.rb +14 -6
  83. metadata +8 -3
data/lib/rubocop.rb CHANGED
@@ -4,9 +4,9 @@ require 'English'
4
4
  before_us = $LOADED_FEATURES.dup
5
5
  require 'rainbow'
6
6
 
7
- require 'set'
8
7
  require 'forwardable'
9
8
  require 'regexp_parser'
9
+ require 'set'
10
10
  require 'unicode/display_width'
11
11
 
12
12
  # we have to require RuboCop's version, before rubocop-ast's
@@ -14,21 +14,24 @@ require_relative 'rubocop/version'
14
14
  require 'rubocop-ast'
15
15
 
16
16
  require_relative 'rubocop/ast_aliases'
17
+ require_relative 'rubocop/ext/range'
17
18
  require_relative 'rubocop/ext/regexp_node'
18
19
  require_relative 'rubocop/ext/regexp_parser'
19
- require_relative 'rubocop/ext/range'
20
20
 
21
21
  require_relative 'rubocop/core_ext/string'
22
22
  require_relative 'rubocop/ext/processed_source'
23
23
 
24
- require_relative 'rubocop/path_util'
24
+ require_relative 'rubocop/error'
25
25
  require_relative 'rubocop/file_finder'
26
- require_relative 'rubocop/platform'
27
26
  require_relative 'rubocop/name_similarity'
27
+ require_relative 'rubocop/optimized_patterns'
28
+ require_relative 'rubocop/path_util'
29
+ require_relative 'rubocop/platform'
28
30
  require_relative 'rubocop/string_interpreter'
29
- require_relative 'rubocop/error'
30
- require_relative 'rubocop/warning'
31
31
  require_relative 'rubocop/util'
32
+ require_relative 'rubocop/warning'
33
+
34
+ # rubocop:disable Style/RequireOrder
32
35
 
33
36
  require_relative 'rubocop/cop/util'
34
37
  require_relative 'rubocop/cop/offense'
@@ -440,6 +443,7 @@ require_relative 'rubocop/cop/style/alias'
440
443
  require_relative 'rubocop/cop/style/and_or'
441
444
  require_relative 'rubocop/cop/style/arguments_forwarding'
442
445
  require_relative 'rubocop/cop/style/array_coercion'
446
+ require_relative 'rubocop/cop/style/array_intersect'
443
447
  require_relative 'rubocop/cop/style/array_join'
444
448
  require_relative 'rubocop/cop/style/ascii_comments'
445
449
  require_relative 'rubocop/cop/style/attr'
@@ -540,12 +544,14 @@ require_relative 'rubocop/cop/style/numbered_parameters'
540
544
  require_relative 'rubocop/cop/style/open_struct_use'
541
545
  require_relative 'rubocop/cop/style/operator_method_call'
542
546
  require_relative 'rubocop/cop/style/redundant_assignment'
547
+ require_relative 'rubocop/cop/style/redundant_constant_base'
543
548
  require_relative 'rubocop/cop/style/redundant_each'
544
549
  require_relative 'rubocop/cop/style/redundant_fetch_block'
545
550
  require_relative 'rubocop/cop/style/redundant_file_extension_in_require'
546
551
  require_relative 'rubocop/cop/style/redundant_initialize'
547
552
  require_relative 'rubocop/cop/style/redundant_self_assignment'
548
553
  require_relative 'rubocop/cop/style/redundant_self_assignment_branch'
554
+ require_relative 'rubocop/cop/style/require_order'
549
555
  require_relative 'rubocop/cop/style/sole_nested_conditional'
550
556
  require_relative 'rubocop/cop/style/static_class'
551
557
  require_relative 'rubocop/cop/style/map_compact_with_conditional_block'
@@ -720,6 +726,8 @@ require_relative 'rubocop/remote_config'
720
726
  require_relative 'rubocop/target_ruby'
721
727
  require_relative 'rubocop/yaml_duplication_checker'
722
728
 
729
+ # rubocop:enable Style/RequireOrder
730
+
723
731
  unless File.exist?("#{__dir__}/../rubocop.gemspec") # Check if we are a gem
724
732
  RuboCop::ResultCache.rubocop_required_features = $LOADED_FEATURES - before_us
725
733
  end
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.38.0
4
+ version: 1.40.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-11-01 00:00:00.000000000 Z
13
+ date: 2022-12-08 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: json
@@ -291,6 +291,7 @@ files:
291
291
  - lib/rubocop/cop/internal_affairs/example_description.rb
292
292
  - lib/rubocop/cop/internal_affairs/example_heredoc_delimiter.rb
293
293
  - lib/rubocop/cop/internal_affairs/inherit_deprecated_cop_class.rb
294
+ - lib/rubocop/cop/internal_affairs/lambda_or_proc.rb
294
295
  - lib/rubocop/cop/internal_affairs/location_line_equality_comparison.rb
295
296
  - lib/rubocop/cop/internal_affairs/method_name_end_with.rb
296
297
  - lib/rubocop/cop/internal_affairs/method_name_equal.rb
@@ -662,6 +663,7 @@ files:
662
663
  - lib/rubocop/cop/style/and_or.rb
663
664
  - lib/rubocop/cop/style/arguments_forwarding.rb
664
665
  - lib/rubocop/cop/style/array_coercion.rb
666
+ - lib/rubocop/cop/style/array_intersect.rb
665
667
  - lib/rubocop/cop/style/array_join.rb
666
668
  - lib/rubocop/cop/style/ascii_comments.rb
667
669
  - lib/rubocop/cop/style/attr.rb
@@ -821,6 +823,7 @@ files:
821
823
  - lib/rubocop/cop/style/redundant_capital_w.rb
822
824
  - lib/rubocop/cop/style/redundant_condition.rb
823
825
  - lib/rubocop/cop/style/redundant_conditional.rb
826
+ - lib/rubocop/cop/style/redundant_constant_base.rb
824
827
  - lib/rubocop/cop/style/redundant_each.rb
825
828
  - lib/rubocop/cop/style/redundant_exception.rb
826
829
  - lib/rubocop/cop/style/redundant_fetch_block.rb
@@ -840,6 +843,7 @@ files:
840
843
  - lib/rubocop/cop/style/redundant_sort_by.rb
841
844
  - lib/rubocop/cop/style/redundant_string_escape.rb
842
845
  - lib/rubocop/cop/style/regexp_literal.rb
846
+ - lib/rubocop/cop/style/require_order.rb
843
847
  - lib/rubocop/cop/style/rescue_modifier.rb
844
848
  - lib/rubocop/cop/style/rescue_standard_error.rb
845
849
  - lib/rubocop/cop/style/return_nil.rb
@@ -940,6 +944,7 @@ files:
940
944
  - lib/rubocop/lockfile.rb
941
945
  - lib/rubocop/magic_comment.rb
942
946
  - lib/rubocop/name_similarity.rb
947
+ - lib/rubocop/optimized_patterns.rb
943
948
  - lib/rubocop/options.rb
944
949
  - lib/rubocop/path_util.rb
945
950
  - lib/rubocop/platform.rb
@@ -985,7 +990,7 @@ metadata:
985
990
  homepage_uri: https://rubocop.org/
986
991
  changelog_uri: https://github.com/rubocop/rubocop/blob/master/CHANGELOG.md
987
992
  source_code_uri: https://github.com/rubocop/rubocop/
988
- documentation_uri: https://docs.rubocop.org/rubocop/1.38/
993
+ documentation_uri: https://docs.rubocop.org/rubocop/1.40/
989
994
  bug_tracker_uri: https://github.com/rubocop/rubocop/issues
990
995
  rubygems_mfa_required: 'true'
991
996
  post_install_message: