rubocop 1.6.1 → 1.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/config/default.yml +48 -6
  4. data/lib/rubocop.rb +4 -0
  5. data/lib/rubocop/config.rb +8 -5
  6. data/lib/rubocop/config_loader.rb +10 -6
  7. data/lib/rubocop/config_loader_resolver.rb +21 -4
  8. data/lib/rubocop/config_obsoletion.rb +5 -3
  9. data/lib/rubocop/cop/gemspec/required_ruby_version.rb +3 -2
  10. data/lib/rubocop/cop/internal_affairs.rb +1 -0
  11. data/lib/rubocop/cop/internal_affairs/style_detected_api_use.rb +145 -0
  12. data/lib/rubocop/cop/layout/empty_line_between_defs.rb +19 -3
  13. data/lib/rubocop/cop/layout/heredoc_argument_closing_parenthesis.rb +14 -0
  14. data/lib/rubocop/cop/layout/rescue_ensure_alignment.rb +3 -10
  15. data/lib/rubocop/cop/layout/space_around_equals_in_parameter_default.rb +1 -0
  16. data/lib/rubocop/cop/layout/space_before_block_braces.rb +2 -0
  17. data/lib/rubocop/cop/layout/space_before_brackets.rb +64 -0
  18. data/lib/rubocop/cop/layout/space_inside_block_braces.rb +13 -10
  19. data/lib/rubocop/cop/layout/space_inside_hash_literal_braces.rb +2 -2
  20. data/lib/rubocop/cop/lint/ambiguous_assignment.rb +59 -0
  21. data/lib/rubocop/cop/lint/binary_operator_with_identical_operands.rb +7 -2
  22. data/lib/rubocop/cop/lint/duplicate_branch.rb +64 -2
  23. data/lib/rubocop/cop/lint/redundant_splat_expansion.rb +50 -17
  24. data/lib/rubocop/cop/lint/shadowed_exception.rb +1 -11
  25. data/lib/rubocop/cop/lint/unreachable_loop.rb +17 -0
  26. data/lib/rubocop/cop/metrics/utils/code_length_calculator.rb +1 -1
  27. data/lib/rubocop/cop/naming/memoized_instance_variable_name.rb +59 -5
  28. data/lib/rubocop/cop/registry.rb +10 -0
  29. data/lib/rubocop/cop/style/access_modifier_declarations.rb +3 -1
  30. data/lib/rubocop/cop/style/collection_methods.rb +14 -1
  31. data/lib/rubocop/cop/style/commented_keyword.rb +22 -5
  32. data/lib/rubocop/cop/style/for.rb +2 -0
  33. data/lib/rubocop/cop/style/hash_except.rb +95 -0
  34. data/lib/rubocop/cop/style/keyword_parameters_order.rb +12 -2
  35. data/lib/rubocop/cop/style/lambda_call.rb +2 -1
  36. data/lib/rubocop/cop/style/method_call_with_args_parentheses.rb +3 -0
  37. data/lib/rubocop/cop/style/method_call_with_args_parentheses/omit_parentheses.rb +16 -6
  38. data/lib/rubocop/cop/style/method_def_parentheses.rb +7 -0
  39. data/lib/rubocop/cop/style/multiline_method_signature.rb +26 -1
  40. data/lib/rubocop/cop/style/multiline_when_then.rb +3 -1
  41. data/lib/rubocop/cop/style/mutable_constant.rb +13 -3
  42. data/lib/rubocop/cop/style/raise_args.rb +2 -0
  43. data/lib/rubocop/cop/style/redundant_argument.rb +7 -1
  44. data/lib/rubocop/cop/style/redundant_freeze.rb +8 -4
  45. data/lib/rubocop/cop/style/single_line_methods.rb +4 -0
  46. data/lib/rubocop/cop/style/symbol_proc.rb +5 -4
  47. data/lib/rubocop/cop/util.rb +3 -1
  48. data/lib/rubocop/options.rb +9 -9
  49. data/lib/rubocop/rspec/cop_helper.rb +0 -4
  50. data/lib/rubocop/rspec/expect_offense.rb +34 -22
  51. data/lib/rubocop/runner.rb +16 -1
  52. data/lib/rubocop/target_finder.rb +4 -2
  53. data/lib/rubocop/util.rb +16 -0
  54. data/lib/rubocop/version.rb +8 -2
  55. metadata +8 -3
@@ -323,11 +323,16 @@ module RuboCop
323
323
  Cop::Team.mobilize(mobilized_cop_classes(config), config, @options)
324
324
  end
325
325
 
326
- def mobilized_cop_classes(config)
326
+ def mobilized_cop_classes(config) # rubocop:disable Metrics/AbcSize
327
327
  @mobilized_cop_classes ||= {}.compare_by_identity
328
328
  @mobilized_cop_classes[config] ||= begin
329
329
  cop_classes = Cop::Registry.all
330
330
 
331
+ # `@options[:only]` and `@options[:except]` are not qualified until
332
+ # needed so that the Registry can be fully loaded, including any
333
+ # cops added by `require`s.
334
+ qualify_option_cop_names
335
+
331
336
  OptionsValidator.new(@options).validate_cop_options
332
337
 
333
338
  if @options[:only]
@@ -342,6 +347,16 @@ module RuboCop
342
347
  end
343
348
  end
344
349
 
350
+ def qualify_option_cop_names
351
+ %i[only except].each do |option|
352
+ next unless @options[option]
353
+
354
+ @options[option].map! do |cop_name|
355
+ Cop::Registry.qualified_cop_name(cop_name, "--#{option} option")
356
+ end
357
+ end
358
+ end
359
+
345
360
  def filter_cop_classes(cop_classes, config)
346
361
  # use only cops that link to a style guide if requested
347
362
  return unless style_guide_cops_only?(config)
@@ -58,7 +58,7 @@ module RuboCop
58
58
  base_dir = base_dir.gsub(File::ALT_SEPARATOR, File::SEPARATOR) if File::ALT_SEPARATOR
59
59
  all_files = find_files(base_dir, File::FNM_DOTMATCH)
60
60
  # use file.include? for performance optimization
61
- hidden_files = all_files.select { |file| file.include?(HIDDEN_PATH_SUBSTRING) }
61
+ hidden_files = all_files.select { |file| file.include?(HIDDEN_PATH_SUBSTRING) }.sort
62
62
  base_dir_config = @config_store.for(base_dir)
63
63
 
64
64
  target_files = all_files.select do |file|
@@ -70,7 +70,9 @@ module RuboCop
70
70
 
71
71
  def to_inspect?(file, hidden_files, base_dir_config)
72
72
  return false if base_dir_config.file_to_exclude?(file)
73
- return true if !hidden_files.include?(file) && ruby_file?(file)
73
+ return true if !hidden_files.bsearch do |hidden_file|
74
+ file <=> hidden_file
75
+ end && ruby_file?(file)
74
76
 
75
77
  base_dir_config.file_to_include?(file)
76
78
  end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RuboCop
4
+ # This module contains a collection of useful utility methods.
5
+ module Util
6
+ def self.silence_warnings
7
+ # Replaces Kernel::silence_warnings since it hides any warnings,
8
+ # including the RuboCop ones
9
+ old_verbose = $VERBOSE
10
+ $VERBOSE = nil
11
+ yield
12
+ ensure
13
+ $VERBOSE = old_verbose
14
+ end
15
+ end
16
+ 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.6.1'
6
+ STRING = '1.7.0'
7
7
 
8
8
  MSG = '%<version>s (using Parser %<parser_version>s, '\
9
9
  'rubocop-ast %<rubocop_ast_version>s, ' \
@@ -34,7 +34,13 @@ module RuboCop
34
34
 
35
35
  # @api private
36
36
  def self.extension_versions(env)
37
- env.config_store.for_pwd.loaded_features.sort.map do |loaded_feature|
37
+ features = Util.silence_warnings do
38
+ # Suppress any config issues when loading the config (ie. deprecations,
39
+ # pending cops, etc.).
40
+ env.config_store.for_pwd.loaded_features.sort
41
+ end
42
+
43
+ features.map do |loaded_feature|
38
44
  next unless (match = loaded_feature.match(/rubocop-(?<feature>.*)/))
39
45
 
40
46
  feature = match[:feature]
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.6.1
4
+ version: 1.7.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: 2020-12-10 00:00:00.000000000 Z
13
+ date: 2020-12-25 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: parallel
@@ -258,6 +258,7 @@ files:
258
258
  - lib/rubocop/cop/internal_affairs/offense_location_keyword.rb
259
259
  - lib/rubocop/cop/internal_affairs/redundant_location_argument.rb
260
260
  - lib/rubocop/cop/internal_affairs/redundant_message_argument.rb
261
+ - lib/rubocop/cop/internal_affairs/style_detected_api_use.rb
261
262
  - lib/rubocop/cop/internal_affairs/useless_message_assertion.rb
262
263
  - lib/rubocop/cop/layout/access_modifier_indentation.rb
263
264
  - lib/rubocop/cop/layout/argument_alignment.rb
@@ -335,6 +336,7 @@ files:
335
336
  - lib/rubocop/cop/layout/space_around_method_call_operator.rb
336
337
  - lib/rubocop/cop/layout/space_around_operators.rb
337
338
  - lib/rubocop/cop/layout/space_before_block_braces.rb
339
+ - lib/rubocop/cop/layout/space_before_brackets.rb
338
340
  - lib/rubocop/cop/layout/space_before_comma.rb
339
341
  - lib/rubocop/cop/layout/space_before_comment.rb
340
342
  - lib/rubocop/cop/layout/space_before_first_arg.rb
@@ -353,6 +355,7 @@ files:
353
355
  - lib/rubocop/cop/layout/trailing_whitespace.rb
354
356
  - lib/rubocop/cop/legacy/corrections_proxy.rb
355
357
  - lib/rubocop/cop/legacy/corrector.rb
358
+ - lib/rubocop/cop/lint/ambiguous_assignment.rb
356
359
  - lib/rubocop/cop/lint/ambiguous_block_association.rb
357
360
  - lib/rubocop/cop/lint/ambiguous_operator.rb
358
361
  - lib/rubocop/cop/lint/ambiguous_regexp_literal.rb
@@ -639,6 +642,7 @@ files:
639
642
  - lib/rubocop/cop/style/guard_clause.rb
640
643
  - lib/rubocop/cop/style/hash_as_last_array_item.rb
641
644
  - lib/rubocop/cop/style/hash_each_methods.rb
645
+ - lib/rubocop/cop/style/hash_except.rb
642
646
  - lib/rubocop/cop/style/hash_like_case.rb
643
647
  - lib/rubocop/cop/style/hash_syntax.rb
644
648
  - lib/rubocop/cop/style/hash_transform_keys.rb
@@ -836,6 +840,7 @@ files:
836
840
  - lib/rubocop/string_interpreter.rb
837
841
  - lib/rubocop/target_finder.rb
838
842
  - lib/rubocop/target_ruby.rb
843
+ - lib/rubocop/util.rb
839
844
  - lib/rubocop/version.rb
840
845
  - lib/rubocop/warning.rb
841
846
  - lib/rubocop/yaml_duplication_checker.rb
@@ -846,7 +851,7 @@ metadata:
846
851
  homepage_uri: https://rubocop.org/
847
852
  changelog_uri: https://github.com/rubocop-hq/rubocop/blob/master/CHANGELOG.md
848
853
  source_code_uri: https://github.com/rubocop-hq/rubocop/
849
- documentation_uri: https://docs.rubocop.org/rubocop/1.6/
854
+ documentation_uri: https://docs.rubocop.org/rubocop/1.7/
850
855
  bug_tracker_uri: https://github.com/rubocop-hq/rubocop/issues
851
856
  post_install_message:
852
857
  rdoc_options: []