rubocop 1.34.0 → 1.35.1

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 (87) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/config/default.yml +22 -0
  4. data/lib/rubocop/cli/command/{auto_genenerate_config.rb → auto_generate_config.rb} +0 -0
  5. data/lib/rubocop/config.rb +1 -1
  6. data/lib/rubocop/cop/correctors/parentheses_corrector.rb +32 -2
  7. data/lib/rubocop/cop/gemspec/require_mfa.rb +1 -1
  8. data/lib/rubocop/cop/generator/require_file_injector.rb +2 -2
  9. data/lib/rubocop/cop/internal_affairs/numblock_handler.rb +69 -0
  10. data/lib/rubocop/cop/internal_affairs/single_line_comparison.rb +5 -4
  11. data/lib/rubocop/cop/internal_affairs.rb +1 -0
  12. data/lib/rubocop/cop/layout/block_alignment.rb +2 -0
  13. data/lib/rubocop/cop/layout/block_end_newline.rb +2 -0
  14. data/lib/rubocop/cop/layout/empty_lines_around_access_modifier.rb +5 -2
  15. data/lib/rubocop/cop/layout/empty_lines_around_block_body.rb +2 -0
  16. data/lib/rubocop/cop/layout/end_of_line.rb +4 -4
  17. data/lib/rubocop/cop/layout/first_array_element_indentation.rb +2 -2
  18. data/lib/rubocop/cop/layout/first_hash_element_indentation.rb +2 -2
  19. data/lib/rubocop/cop/layout/indentation_width.rb +2 -0
  20. data/lib/rubocop/cop/layout/line_length.rb +4 -1
  21. data/lib/rubocop/cop/layout/multiline_block_layout.rb +2 -0
  22. data/lib/rubocop/cop/layout/redundant_line_break.rb +1 -1
  23. data/lib/rubocop/cop/layout/space_around_block_parameters.rb +1 -1
  24. data/lib/rubocop/cop/layout/space_around_keyword.rb +1 -1
  25. data/lib/rubocop/cop/layout/space_before_block_braces.rb +2 -0
  26. data/lib/rubocop/cop/lint/deprecated_class_methods.rb +4 -4
  27. data/lib/rubocop/cop/lint/empty_block.rb +1 -1
  28. data/lib/rubocop/cop/lint/erb_new_arguments.rb +9 -9
  29. data/lib/rubocop/cop/lint/literal_in_interpolation.rb +4 -0
  30. data/lib/rubocop/cop/lint/next_without_accumulator.rb +25 -6
  31. data/lib/rubocop/cop/lint/non_atomic_file_operation.rb +6 -6
  32. data/lib/rubocop/cop/lint/non_deterministic_require_order.rb +12 -0
  33. data/lib/rubocop/cop/lint/redundant_safe_navigation.rb +9 -3
  34. data/lib/rubocop/cop/lint/redundant_with_index.rb +13 -10
  35. data/lib/rubocop/cop/lint/redundant_with_object.rb +12 -11
  36. data/lib/rubocop/cop/lint/shadowing_outer_local_variable.rb +1 -0
  37. data/lib/rubocop/cop/lint/unreachable_loop.rb +7 -1
  38. data/lib/rubocop/cop/lint/useless_access_modifier.rb +6 -4
  39. data/lib/rubocop/cop/lint/void.rb +2 -0
  40. data/lib/rubocop/cop/mixin/check_line_breakable.rb +1 -1
  41. data/lib/rubocop/cop/mixin/hash_shorthand_syntax.rb +76 -1
  42. data/lib/rubocop/cop/mixin/hash_transform_method.rb +1 -1
  43. data/lib/rubocop/cop/mixin/method_complexity.rb +4 -4
  44. data/lib/rubocop/cop/mixin/multiline_element_indentation.rb +1 -1
  45. data/lib/rubocop/cop/mixin/range_help.rb +2 -3
  46. data/lib/rubocop/cop/naming/block_parameter_name.rb +1 -1
  47. data/lib/rubocop/cop/naming/constant_name.rb +2 -2
  48. data/lib/rubocop/cop/style/arguments_forwarding.rb +2 -2
  49. data/lib/rubocop/cop/style/class_methods_definitions.rb +2 -1
  50. data/lib/rubocop/cop/style/collection_methods.rb +2 -0
  51. data/lib/rubocop/cop/style/combinable_loops.rb +3 -1
  52. data/lib/rubocop/cop/style/each_for_simple_loop.rb +1 -1
  53. data/lib/rubocop/cop/style/each_with_object.rb +39 -8
  54. data/lib/rubocop/cop/style/empty_block_parameter.rb +1 -1
  55. data/lib/rubocop/cop/style/empty_lambda_parameter.rb +1 -1
  56. data/lib/rubocop/cop/style/for.rb +2 -0
  57. data/lib/rubocop/cop/style/guard_clause.rb +27 -16
  58. data/lib/rubocop/cop/style/hash_each_methods.rb +3 -1
  59. data/lib/rubocop/cop/style/hash_syntax.rb +17 -0
  60. data/lib/rubocop/cop/style/inverse_methods.rb +8 -6
  61. data/lib/rubocop/cop/style/magic_comment_format.rb +307 -0
  62. data/lib/rubocop/cop/style/method_call_with_args_parentheses/omit_parentheses.rb +2 -2
  63. data/lib/rubocop/cop/style/method_called_on_do_end_block.rb +4 -1
  64. data/lib/rubocop/cop/style/multiline_block_chain.rb +3 -1
  65. data/lib/rubocop/cop/style/multiline_in_pattern_then.rb +1 -1
  66. data/lib/rubocop/cop/style/next.rb +3 -5
  67. data/lib/rubocop/cop/style/nil_lambda.rb +1 -1
  68. data/lib/rubocop/cop/style/object_then.rb +2 -0
  69. data/lib/rubocop/cop/style/proc.rb +4 -1
  70. data/lib/rubocop/cop/style/redundant_begin.rb +2 -0
  71. data/lib/rubocop/cop/style/redundant_fetch_block.rb +1 -1
  72. data/lib/rubocop/cop/style/redundant_self.rb +2 -0
  73. data/lib/rubocop/cop/style/redundant_sort_by.rb +24 -8
  74. data/lib/rubocop/cop/style/safe_navigation.rb +4 -2
  75. data/lib/rubocop/cop/style/single_line_block_params.rb +1 -1
  76. data/lib/rubocop/cop/style/sole_nested_conditional.rb +0 -2
  77. data/lib/rubocop/cop/style/symbol_array.rb +1 -1
  78. data/lib/rubocop/cop/style/top_level_method_definition.rb +3 -1
  79. data/lib/rubocop/cop/style/trailing_comma_in_block_args.rb +1 -1
  80. data/lib/rubocop/cop/style/word_array.rb +1 -1
  81. data/lib/rubocop/cop/util.rb +1 -1
  82. data/lib/rubocop/feature_loader.rb +9 -3
  83. data/lib/rubocop/formatter/html_formatter.rb +2 -2
  84. data/lib/rubocop/server/cache.rb +11 -8
  85. data/lib/rubocop/version.rb +1 -1
  86. data/lib/rubocop.rb +3 -2
  87. metadata +9 -7
@@ -30,14 +30,20 @@ module RuboCop
30
30
  end
31
31
 
32
32
  def load
33
- ::Kernel.require(target)
33
+ # Don't use `::Kernel.require(target)` to prevent the following error:
34
+ # https://github.com/rubocop/rubocop/issues/10893
35
+ require(target)
34
36
  rescue ::LoadError => e
35
37
  raise if e.path != target
36
38
 
37
39
  begin
38
- ::Kernel.require(namespaced_target)
40
+ # Don't use `::Kernel.require(target)` to prevent the following error:
41
+ # https://github.com/rubocop/rubocop/issues/10893
42
+ require(namespaced_target)
39
43
  rescue ::LoadError => error_for_namespaced_target
40
- raise e if error_for_namespaced_target.path == namespaced_target
44
+ # NOTE: This wrap is necessary due to JRuby 9.3.4.0 incompatibility:
45
+ # https://github.com/jruby/jruby/issues/7316
46
+ raise LoadError, e if error_for_namespaced_target.path == namespaced_target
41
47
 
42
48
  raise error_for_namespaced_target
43
49
  end
@@ -93,12 +93,12 @@ module RuboCop
93
93
 
94
94
  def highlighted_source_line(offense)
95
95
  source_before_highlight(offense) +
96
- hightlight_source_tag(offense) +
96
+ highlight_source_tag(offense) +
97
97
  source_after_highlight(offense) +
98
98
  possible_ellipses(offense.location)
99
99
  end
100
100
 
101
- def hightlight_source_tag(offense)
101
+ def highlight_source_tag(offense)
102
102
  "<span class=\"highlight #{offense.severity}\">" \
103
103
  "#{escape(offense.highlighted_area.source)}" \
104
104
  '</span>'
@@ -62,17 +62,20 @@ module RuboCop
62
62
  # `RuboCop::ConfigStore` has heavy dependencies, this is a lightweight implementation
63
63
  # so that only the necessary `CacheRootDirectory` can be obtained.
64
64
  require 'yaml'
65
-
66
65
  config_path = ConfigFinder.find_config_path(Dir.pwd)
67
66
 
68
- # Ruby 3.1+
69
- config_yaml = if Gem::Version.new(Psych::VERSION) >= Gem::Version.new('4.0.0')
70
- YAML.safe_load_file(config_path, permitted_classes: [Regexp, Symbol])
71
- else
72
- YAML.load_file(config_path)
73
- end
67
+ require 'erb'
68
+ file_contents = File.read(config_path)
69
+ yaml_code = ERB.new(file_contents).result
70
+
71
+ config_yaml = YAML.safe_load(yaml_code, permitted_classes: [Regexp, Symbol])
72
+
73
+ # For compatibility with Ruby 3.0 or lower.
74
+ if Gem::Version.new(Psych::VERSION) < Gem::Version.new('4.0.0')
75
+ config_yaml == false ? nil : config_yaml
76
+ end
74
77
 
75
- config_yaml.dig('AllCops', 'CacheRootDirectory')
78
+ config_yaml&.dig('AllCops', 'CacheRootDirectory')
76
79
  end
77
80
  end
78
81
 
@@ -3,7 +3,7 @@
3
3
  module RuboCop
4
4
  # This module holds the RuboCop version information.
5
5
  module Version
6
- STRING = '1.34.0'
6
+ STRING = '1.35.1'
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
@@ -48,6 +48,7 @@ require_relative 'rubocop/cop/severity'
48
48
  require_relative 'rubocop/cop/generator'
49
49
  require_relative 'rubocop/cop/generator/configuration_injector'
50
50
  require_relative 'rubocop/cop/generator/require_file_injector'
51
+ require_relative 'rubocop/magic_comment'
51
52
 
52
53
  require_relative 'rubocop/cop/variable_force'
53
54
  require_relative 'rubocop/cop/variable_force/branch'
@@ -529,6 +530,7 @@ require_relative 'rubocop/cop/style/keyword_parameters_order'
529
530
  require_relative 'rubocop/cop/style/lambda'
530
531
  require_relative 'rubocop/cop/style/lambda_call'
531
532
  require_relative 'rubocop/cop/style/line_end_concatenation'
533
+ require_relative 'rubocop/cop/style/magic_comment_format'
532
534
  require_relative 'rubocop/cop/style/map_to_hash'
533
535
  require_relative 'rubocop/cop/style/method_call_without_args_parentheses'
534
536
  require_relative 'rubocop/cop/style/method_call_with_args_parentheses'
@@ -695,14 +697,13 @@ require_relative 'rubocop/lockfile'
695
697
  require_relative 'rubocop/target_finder'
696
698
  require_relative 'rubocop/directive_comment'
697
699
  require_relative 'rubocop/comment_config'
698
- require_relative 'rubocop/magic_comment'
699
700
  require_relative 'rubocop/result_cache'
700
701
  require_relative 'rubocop/runner'
701
702
  require_relative 'rubocop/cli'
702
703
  require_relative 'rubocop/cli/command'
703
704
  require_relative 'rubocop/cli/environment'
704
705
  require_relative 'rubocop/cli/command/base'
705
- require_relative 'rubocop/cli/command/auto_genenerate_config'
706
+ require_relative 'rubocop/cli/command/auto_generate_config'
706
707
  require_relative 'rubocop/cli/command/execute_runner'
707
708
  require_relative 'rubocop/cli/command/init_dotfile'
708
709
  require_relative 'rubocop/cli/command/show_cops'
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.34.0
4
+ version: 1.35.1
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-08-09 00:00:00.000000000 Z
13
+ date: 2022-08-22 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.20.0
123
+ version: 1.20.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.20.0
133
+ version: 1.20.1
134
134
  - - "<"
135
135
  - !ruby/object:Gem::Version
136
136
  version: '2.0'
@@ -212,7 +212,7 @@ files:
212
212
  - lib/rubocop/cached_data.rb
213
213
  - lib/rubocop/cli.rb
214
214
  - lib/rubocop/cli/command.rb
215
- - lib/rubocop/cli/command/auto_genenerate_config.rb
215
+ - lib/rubocop/cli/command/auto_generate_config.rb
216
216
  - lib/rubocop/cli/command/base.rb
217
217
  - lib/rubocop/cli/command/execute_runner.rb
218
218
  - lib/rubocop/cli/command/init_dotfile.rb
@@ -293,6 +293,7 @@ files:
293
293
  - lib/rubocop/cop/internal_affairs/node_destructuring.rb
294
294
  - lib/rubocop/cop/internal_affairs/node_matcher_directive.rb
295
295
  - lib/rubocop/cop/internal_affairs/node_type_predicate.rb
296
+ - lib/rubocop/cop/internal_affairs/numblock_handler.rb
296
297
  - lib/rubocop/cop/internal_affairs/offense_location_keyword.rb
297
298
  - lib/rubocop/cop/internal_affairs/redundant_context_config_parameter.rb
298
299
  - lib/rubocop/cop/internal_affairs/redundant_described_class_as_subject.rb
@@ -748,6 +749,7 @@ files:
748
749
  - lib/rubocop/cop/style/lambda.rb
749
750
  - lib/rubocop/cop/style/lambda_call.rb
750
751
  - lib/rubocop/cop/style/line_end_concatenation.rb
752
+ - lib/rubocop/cop/style/magic_comment_format.rb
751
753
  - lib/rubocop/cop/style/map_compact_with_conditional_block.rb
752
754
  - lib/rubocop/cop/style/map_to_hash.rb
753
755
  - lib/rubocop/cop/style/method_call_with_args_parentheses.rb
@@ -975,7 +977,7 @@ metadata:
975
977
  homepage_uri: https://rubocop.org/
976
978
  changelog_uri: https://github.com/rubocop/rubocop/blob/master/CHANGELOG.md
977
979
  source_code_uri: https://github.com/rubocop/rubocop/
978
- documentation_uri: https://docs.rubocop.org/rubocop/1.34/
980
+ documentation_uri: https://docs.rubocop.org/rubocop/1.35/
979
981
  bug_tracker_uri: https://github.com/rubocop/rubocop/issues
980
982
  rubygems_mfa_required: 'true'
981
983
  post_install_message:
@@ -993,7 +995,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
993
995
  - !ruby/object:Gem::Version
994
996
  version: '0'
995
997
  requirements: []
996
- rubygems_version: 3.2.22
998
+ rubygems_version: 3.1.2
997
999
  signing_key:
998
1000
  specification_version: 4
999
1001
  summary: Automatic Ruby code style checking tool.