rubocop 1.39.0 → 1.40.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (63) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/config/default.yml +47 -9
  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/lint/ambiguous_block_association.rb +1 -1
  14. data/lib/rubocop/cop/lint/assignment_in_condition.rb +11 -1
  15. data/lib/rubocop/cop/lint/deprecated_constants.rb +8 -1
  16. data/lib/rubocop/cop/lint/empty_block.rb +1 -5
  17. data/lib/rubocop/cop/lint/empty_conditional_body.rb +1 -1
  18. data/lib/rubocop/cop/lint/interpolation_check.rb +4 -3
  19. data/lib/rubocop/cop/lint/parentheses_as_grouped_expression.rb +5 -0
  20. data/lib/rubocop/cop/lint/redundant_cop_disable_directive.rb +13 -3
  21. data/lib/rubocop/cop/lint/safe_navigation_chain.rb +15 -6
  22. data/lib/rubocop/cop/lint/send_with_mixin_argument.rb +5 -4
  23. data/lib/rubocop/cop/lint/shadowing_outer_local_variable.rb +4 -3
  24. data/lib/rubocop/cop/lint/void.rb +6 -6
  25. data/lib/rubocop/cop/metrics/block_length.rb +9 -4
  26. data/lib/rubocop/cop/metrics/class_length.rb +9 -4
  27. data/lib/rubocop/cop/metrics/method_length.rb +9 -4
  28. data/lib/rubocop/cop/metrics/module_length.rb +9 -4
  29. data/lib/rubocop/cop/metrics/utils/code_length_calculator.rb +5 -2
  30. data/lib/rubocop/cop/mixin/hash_shorthand_syntax.rb +24 -5
  31. data/lib/rubocop/cop/mixin/statement_modifier.rb +15 -1
  32. data/lib/rubocop/cop/registry.rb +23 -11
  33. data/lib/rubocop/cop/style/array_intersect.rb +111 -0
  34. data/lib/rubocop/cop/style/guard_clause.rb +32 -5
  35. data/lib/rubocop/cop/style/if_with_semicolon.rb +2 -1
  36. data/lib/rubocop/cop/style/nil_lambda.rb +1 -1
  37. data/lib/rubocop/cop/style/redundant_argument.rb +3 -0
  38. data/lib/rubocop/cop/style/redundant_constant_base.rb +72 -0
  39. data/lib/rubocop/cop/style/redundant_return.rb +7 -0
  40. data/lib/rubocop/cop/style/redundant_sort.rb +1 -1
  41. data/lib/rubocop/cop/style/require_order.rb +88 -0
  42. data/lib/rubocop/cop/style/safe_navigation.rb +35 -6
  43. data/lib/rubocop/cop/style/select_by_regexp.rb +8 -4
  44. data/lib/rubocop/cop/style/string_literals.rb +1 -5
  45. data/lib/rubocop/cop/style/symbol_proc.rb +2 -4
  46. data/lib/rubocop/cop/team.rb +1 -1
  47. data/lib/rubocop/cop/util.rb +1 -1
  48. data/lib/rubocop/cop/variable_force/assignment.rb +1 -1
  49. data/lib/rubocop/cop/variable_force.rb +20 -29
  50. data/lib/rubocop/formatter/disabled_config_formatter.rb +17 -6
  51. data/lib/rubocop/formatter/html_formatter.rb +1 -1
  52. data/lib/rubocop/formatter.rb +3 -1
  53. data/lib/rubocop/optimized_patterns.rb +38 -0
  54. data/lib/rubocop/options.rb +9 -1
  55. data/lib/rubocop/path_util.rb +14 -2
  56. data/lib/rubocop/result_cache.rb +1 -1
  57. data/lib/rubocop/rspec/cop_helper.rb +4 -1
  58. data/lib/rubocop/rspec/support.rb +2 -2
  59. data/lib/rubocop/server/core.rb +1 -1
  60. data/lib/rubocop/target_ruby.rb +1 -1
  61. data/lib/rubocop/version.rb +1 -1
  62. data/lib/rubocop.rb +14 -6
  63. metadata +8 -3
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'socket'
4
3
  require 'securerandom'
4
+ require 'socket'
5
5
 
6
6
  #
7
7
  # This code is based on https://github.com/fohte/rubocop-daemon.
@@ -84,7 +84,7 @@ module RuboCop
84
84
  # @api private
85
85
  class ToolVersionsFile < RubyVersionFile
86
86
  TOOL_VERSIONS_FILENAME = '.tool-versions'
87
- TOOL_VERSIONS_PATTERN = /\Aruby (?:ruby-)?(?<version>\d+\.\d+)/.freeze
87
+ TOOL_VERSIONS_PATTERN = /^(?:ruby )(?<version>\d+\.\d+)/.freeze
88
88
 
89
89
  def name
90
90
  "`#{TOOL_VERSIONS_FILENAME}`"
@@ -3,7 +3,7 @@
3
3
  module RuboCop
4
4
  # This module holds the RuboCop version information.
5
5
  module Version
6
- STRING = '1.39.0'
6
+ STRING = '1.40.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
@@ -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.39.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-14 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.39/
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: