rubocop 1.37.0 → 1.38.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/config/default.yml +6 -0
  4. data/lib/rubocop/cli/command/suggest_extensions.rb +8 -1
  5. data/lib/rubocop/comment_config.rb +36 -1
  6. data/lib/rubocop/cop/commissioner.rb +3 -1
  7. data/lib/rubocop/cop/internal_affairs/create_empty_file.rb +37 -0
  8. data/lib/rubocop/cop/internal_affairs/example_heredoc_delimiter.rb +111 -0
  9. data/lib/rubocop/cop/internal_affairs.rb +2 -0
  10. data/lib/rubocop/cop/layout/indentation_style.rb +1 -1
  11. data/lib/rubocop/cop/layout/line_continuation_spacing.rb +1 -1
  12. data/lib/rubocop/cop/layout/space_inside_hash_literal_braces.rb +2 -0
  13. data/lib/rubocop/cop/layout/space_inside_reference_brackets.rb +6 -2
  14. data/lib/rubocop/cop/lint/empty_conditional_body.rb +1 -1
  15. data/lib/rubocop/cop/lint/missing_cop_enable_directive.rb +18 -3
  16. data/lib/rubocop/cop/lint/redundant_cop_disable_directive.rb +11 -0
  17. data/lib/rubocop/cop/lint/redundant_require_statement.rb +10 -2
  18. data/lib/rubocop/cop/mixin/surrounding_space.rb +4 -3
  19. data/lib/rubocop/cop/registry.rb +10 -4
  20. data/lib/rubocop/cop/style/access_modifier_declarations.rb +3 -1
  21. data/lib/rubocop/cop/style/block_delimiters.rb +1 -1
  22. data/lib/rubocop/cop/style/character_literal.rb +1 -1
  23. data/lib/rubocop/cop/style/collection_compact.rb +6 -2
  24. data/lib/rubocop/cop/style/guard_clause.rb +62 -21
  25. data/lib/rubocop/cop/style/if_with_boolean_literal_branches.rb +25 -2
  26. data/lib/rubocop/cop/style/module_function.rb +28 -6
  27. data/lib/rubocop/cop/style/operator_method_call.rb +2 -1
  28. data/lib/rubocop/cop/style/redundant_each.rb +111 -0
  29. data/lib/rubocop/cop/style/redundant_string_escape.rb +13 -5
  30. data/lib/rubocop/cop/team.rb +3 -4
  31. data/lib/rubocop/cop/variable_force/variable_table.rb +1 -1
  32. data/lib/rubocop/cops_documentation_generator.rb +4 -2
  33. data/lib/rubocop/ext/processed_source.rb +2 -0
  34. data/lib/rubocop/formatter/offense_count_formatter.rb +8 -5
  35. data/lib/rubocop/formatter/worst_offenders_formatter.rb +6 -3
  36. data/lib/rubocop/options.rb +6 -2
  37. data/lib/rubocop/rspec/cop_helper.rb +21 -1
  38. data/lib/rubocop/rspec/shared_contexts.rb +13 -12
  39. data/lib/rubocop/runner.rb +15 -11
  40. data/lib/rubocop/server/core.rb +1 -0
  41. data/lib/rubocop/version.rb +1 -1
  42. data/lib/rubocop.rb +1 -0
  43. metadata +8 -5
@@ -423,17 +423,21 @@ module RuboCop
423
423
  end
424
424
 
425
425
  def get_processed_source(file)
426
- ruby_version = @config_store.for_file(file).target_ruby_version
427
-
428
- if @options[:stdin]
429
- ProcessedSource.new(@options[:stdin], ruby_version, file)
430
- else
431
- begin
432
- ProcessedSource.from_file(file, ruby_version)
433
- rescue Errno::ENOENT
434
- raise RuboCop::Error, "No such file or directory: #{file}"
435
- end
436
- end
426
+ config = @config_store.for_file(file)
427
+ ruby_version = config.target_ruby_version
428
+
429
+ processed_source = if @options[:stdin]
430
+ ProcessedSource.new(@options[:stdin], ruby_version, file)
431
+ else
432
+ begin
433
+ ProcessedSource.from_file(file, ruby_version)
434
+ rescue Errno::ENOENT
435
+ raise RuboCop::Error, "No such file or directory: #{file}"
436
+ end
437
+ end
438
+ processed_source.config = config
439
+ processed_source.registry = mobilized_cop_classes(config)
440
+ processed_source
437
441
  end
438
442
 
439
443
  # A Cop::Team instance is stateful and may change when inspecting.
@@ -41,6 +41,7 @@ module RuboCop
41
41
 
42
42
  pid = fork do
43
43
  Process.daemon(true)
44
+ $stderr.reopen(Cache.stderr_path, 'w')
44
45
  Cache.write_pid_file do
45
46
  read_socket(@server.accept) until @server.closed?
46
47
  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.37.0'
6
+ STRING = '1.38.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
@@ -540,6 +540,7 @@ require_relative 'rubocop/cop/style/numbered_parameters'
540
540
  require_relative 'rubocop/cop/style/open_struct_use'
541
541
  require_relative 'rubocop/cop/style/operator_method_call'
542
542
  require_relative 'rubocop/cop/style/redundant_assignment'
543
+ require_relative 'rubocop/cop/style/redundant_each'
543
544
  require_relative 'rubocop/cop/style/redundant_fetch_block'
544
545
  require_relative 'rubocop/cop/style/redundant_file_extension_in_require'
545
546
  require_relative 'rubocop/cop/style/redundant_initialize'
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.37.0
4
+ version: 1.38.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-10-20 00:00:00.000000000 Z
13
+ date: 2022-11-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.22.0
123
+ version: 1.23.0
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.22.0
133
+ version: 1.23.0
134
134
  - - "<"
135
135
  - !ruby/object:Gem::Version
136
136
  version: '2.0'
@@ -286,8 +286,10 @@ files:
286
286
  - lib/rubocop/cop/ignored_node.rb
287
287
  - lib/rubocop/cop/internal_affairs.rb
288
288
  - lib/rubocop/cop/internal_affairs/cop_description.rb
289
+ - lib/rubocop/cop/internal_affairs/create_empty_file.rb
289
290
  - lib/rubocop/cop/internal_affairs/empty_line_between_expect_offense_and_correction.rb
290
291
  - lib/rubocop/cop/internal_affairs/example_description.rb
292
+ - lib/rubocop/cop/internal_affairs/example_heredoc_delimiter.rb
291
293
  - lib/rubocop/cop/internal_affairs/inherit_deprecated_cop_class.rb
292
294
  - lib/rubocop/cop/internal_affairs/location_line_equality_comparison.rb
293
295
  - lib/rubocop/cop/internal_affairs/method_name_end_with.rb
@@ -819,6 +821,7 @@ files:
819
821
  - lib/rubocop/cop/style/redundant_capital_w.rb
820
822
  - lib/rubocop/cop/style/redundant_condition.rb
821
823
  - lib/rubocop/cop/style/redundant_conditional.rb
824
+ - lib/rubocop/cop/style/redundant_each.rb
822
825
  - lib/rubocop/cop/style/redundant_exception.rb
823
826
  - lib/rubocop/cop/style/redundant_fetch_block.rb
824
827
  - lib/rubocop/cop/style/redundant_file_extension_in_require.rb
@@ -982,7 +985,7 @@ metadata:
982
985
  homepage_uri: https://rubocop.org/
983
986
  changelog_uri: https://github.com/rubocop/rubocop/blob/master/CHANGELOG.md
984
987
  source_code_uri: https://github.com/rubocop/rubocop/
985
- documentation_uri: https://docs.rubocop.org/rubocop/1.37/
988
+ documentation_uri: https://docs.rubocop.org/rubocop/1.38/
986
989
  bug_tracker_uri: https://github.com/rubocop/rubocop/issues
987
990
  rubygems_mfa_required: 'true'
988
991
  post_install_message: