rubocop 1.3.1 → 1.5.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (70) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/config/default.yml +67 -11
  4. data/lib/rubocop.rb +5 -0
  5. data/lib/rubocop/cli.rb +5 -1
  6. data/lib/rubocop/cli/command/execute_runner.rb +26 -11
  7. data/lib/rubocop/cli/command/suggest_extensions.rb +80 -0
  8. data/lib/rubocop/config_loader.rb +1 -1
  9. data/lib/rubocop/config_loader_resolver.rb +5 -1
  10. data/lib/rubocop/config_obsoletion.rb +21 -3
  11. data/lib/rubocop/config_regeneration.rb +1 -1
  12. data/lib/rubocop/config_validator.rb +8 -1
  13. data/lib/rubocop/cop/autocorrect_logic.rb +21 -6
  14. data/lib/rubocop/cop/correctors/percent_literal_corrector.rb +1 -1
  15. data/lib/rubocop/cop/generator.rb +1 -1
  16. data/lib/rubocop/cop/internal_affairs/useless_message_assertion.rb +1 -1
  17. data/lib/rubocop/cop/layout/empty_line_between_defs.rb +80 -10
  18. data/lib/rubocop/cop/layout/empty_lines_around_arguments.rb +6 -1
  19. data/lib/rubocop/cop/layout/end_of_line.rb +5 -5
  20. data/lib/rubocop/cop/layout/first_argument_indentation.rb +7 -2
  21. data/lib/rubocop/cop/layout/space_around_method_call_operator.rb +1 -1
  22. data/lib/rubocop/cop/lint/ambiguous_regexp_literal.rb +2 -1
  23. data/lib/rubocop/cop/lint/interpolation_check.rb +7 -2
  24. data/lib/rubocop/cop/lint/literal_in_interpolation.rb +1 -1
  25. data/lib/rubocop/cop/lint/missing_super.rb +7 -4
  26. data/lib/rubocop/cop/lint/no_return_in_begin_end_blocks.rb +1 -1
  27. data/lib/rubocop/cop/lint/unexpected_block_arity.rb +85 -0
  28. data/lib/rubocop/cop/lint/unmodified_reduce_accumulator.rb +20 -6
  29. data/lib/rubocop/cop/metrics/abc_size.rb +25 -1
  30. data/lib/rubocop/cop/metrics/block_length.rb +13 -7
  31. data/lib/rubocop/cop/metrics/method_length.rb +7 -2
  32. data/lib/rubocop/cop/metrics/parameter_lists.rb +64 -1
  33. data/lib/rubocop/cop/metrics/utils/abc_size_calculator.rb +20 -10
  34. data/lib/rubocop/cop/metrics/utils/repeated_attribute_discount.rb +146 -0
  35. data/lib/rubocop/cop/metrics/utils/repeated_csend_discount.rb +6 -1
  36. data/lib/rubocop/cop/mixin/configurable_numbering.rb +3 -2
  37. data/lib/rubocop/cop/mixin/enforce_superclass.rb +9 -1
  38. data/lib/rubocop/cop/mixin/ignored_methods.rb +36 -3
  39. data/lib/rubocop/cop/mixin/method_complexity.rb +6 -0
  40. data/lib/rubocop/cop/mixin/multiline_expression_indentation.rb +1 -1
  41. data/lib/rubocop/cop/mixin/visibility_help.rb +1 -3
  42. data/lib/rubocop/cop/naming/variable_number.rb +3 -1
  43. data/lib/rubocop/cop/style/and_or.rb +10 -0
  44. data/lib/rubocop/cop/style/class_and_module_children.rb +8 -3
  45. data/lib/rubocop/cop/style/documentation.rb +12 -1
  46. data/lib/rubocop/cop/style/format_string.rb +8 -3
  47. data/lib/rubocop/cop/style/if_with_semicolon.rb +39 -4
  48. data/lib/rubocop/cop/style/method_call_with_args_parentheses/omit_parentheses.rb +2 -2
  49. data/lib/rubocop/cop/style/method_call_without_args_parentheses.rb +11 -2
  50. data/lib/rubocop/cop/style/numeric_literals.rb +14 -11
  51. data/lib/rubocop/cop/style/redundant_argument.rb +75 -0
  52. data/lib/rubocop/cop/style/redundant_condition.rb +2 -1
  53. data/lib/rubocop/cop/style/redundant_regexp_escape.rb +1 -1
  54. data/lib/rubocop/cop/style/sole_nested_conditional.rb +49 -3
  55. data/lib/rubocop/cop/style/symbol_proc.rb +5 -3
  56. data/lib/rubocop/cop/util.rb +1 -1
  57. data/lib/rubocop/cop/variable_force/branch.rb +1 -1
  58. data/lib/rubocop/cop/variable_force/scope.rb +1 -1
  59. data/lib/rubocop/core_ext/hash.rb +20 -0
  60. data/lib/rubocop/ext/regexp_node.rb +5 -10
  61. data/lib/rubocop/ext/regexp_parser.rb +2 -9
  62. data/lib/rubocop/formatter/disabled_config_formatter.rb +21 -6
  63. data/lib/rubocop/options.rb +5 -0
  64. data/lib/rubocop/rake_task.rb +2 -2
  65. data/lib/rubocop/runner.rb +1 -1
  66. data/lib/rubocop/version.rb +1 -1
  67. metadata +12 -10
  68. data/bin/console +0 -10
  69. data/bin/rubocop-profile +0 -32
  70. data/bin/setup +0 -7
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4238df3546a63ce2c279ced4bba228a61c137b083a3fad76b45365954555f690
4
- data.tar.gz: bf3bd7a2409203b911212906d013aec7219f1a21825352bc92e0b897faafbd66
3
+ metadata.gz: 6385e74786dea3c867437d18cb40ed5715ed391e14c05f9589b9029b5d8e3b82
4
+ data.tar.gz: 56ca46faf293f235cecc7e9efc3590f355889b837bf2a9d27c224eb62e5a5ac5
5
5
  SHA512:
6
- metadata.gz: a87bd4426855a7278963b8c3e4373b7c995994b5685318aad04bc2b0832c0db44e705d50d4ea21d81eb47074137fde56665f8317121caae8a81e208e044ce4a7
7
- data.tar.gz: 3bb4cb7794129ac95c70876bc009a4ed07425a7a346acaf77279c4e0fc8b1c20f31e82e9590e1d880fa011ddddc08c93bb3851f6f815718b9de8ff7a0dd78c6f
6
+ metadata.gz: 1f7dd2432b886b8a843fb168179d51a1f2944c045261d461a35e3a40942d55de8a837051bb06635482cf29db50f6bb8f4be16bf284a9596d70ab3e1235a296ec
7
+ data.tar.gz: 3cdc1f213db45d58d9ae5f2b05a6ed93d9c5cb18bf096e7ff2c848bdf191f70b1af011401a97c70f54a0a63107a24bb60c7eea50284a3f7b9467e522c3d9b183
data/README.md CHANGED
@@ -51,7 +51,7 @@ To prevent an unwanted RuboCop update you might want to use a conservative versi
51
51
  in your `Gemfile`:
52
52
 
53
53
  ```rb
54
- gem 'rubocop', '~> 1.3', require: false
54
+ gem 'rubocop', '~> 1.5', require: false
55
55
  ```
56
56
 
57
57
  See [versioning](https://docs.rubocop.org/rubocop/1.0/versioning.html) for further details.
@@ -139,6 +139,16 @@ AllCops:
139
139
  # from the lock file.) If the Ruby version is still unresolved, RuboCop will
140
140
  # use the oldest officially supported Ruby version (currently Ruby 2.4).
141
141
  TargetRubyVersion: ~
142
+ # Determines if a notification for extension libraries should be shown when
143
+ # rubocop is run. Keys are the name of the extension, and values are an array
144
+ # of gems in the Gemfile that the extension is suggested for, if not already
145
+ # included.
146
+ SuggestExtensions:
147
+ rubocop-rails: [rails]
148
+ rubocop-rspec: [rspec, rspec-rails]
149
+ rubocop-minitest: [minitest]
150
+ rubocop-sequel: [sequel]
151
+ rubocop-rake: [rake]
142
152
 
143
153
  #################### Bundler ###############################
144
154
 
@@ -459,10 +469,14 @@ Layout/EmptyLineAfterMultilineCondition:
459
469
  - https://github.com/airbnb/ruby#multiline-if-newline
460
470
 
461
471
  Layout/EmptyLineBetweenDefs:
462
- Description: 'Use empty lines between defs.'
472
+ Description: 'Use empty lines between class/module/method defs.'
463
473
  StyleGuide: '#empty-lines-between-methods'
464
474
  Enabled: true
465
475
  VersionAdded: '0.49'
476
+ VersionChanged: '1.4'
477
+ EmptyLineBetweenMethodDefs: true
478
+ EmptyLineBetweenClassDefs: true
479
+ EmptyLineBetweenModuleDefs: true
466
480
  # If `true`, this parameter means that single line method definitions don't
467
481
  # need an empty line between them.
468
482
  AllowAdjacentOneLineDefs: false
@@ -891,8 +905,8 @@ Layout/LineLength:
891
905
  StyleGuide: '#max-line-length'
892
906
  Enabled: true
893
907
  VersionAdded: '0.25'
894
- VersionChanged: '1.3'
895
- AutoCorrect: false
908
+ VersionChanged: '1.4'
909
+ AutoCorrect: true
896
910
  Max: 120
897
911
  # To make it possible to copy or click on URIs in the code, we allow lines
898
912
  # containing a URI to be longer than Max.
@@ -1684,6 +1698,7 @@ Lint/MissingSuper:
1684
1698
  without calls to `super`'.
1685
1699
  Enabled: true
1686
1700
  VersionAdded: '0.89'
1701
+ VersionChanged: '1.4'
1687
1702
 
1688
1703
  Lint/MixedRegexpCaptureTypes:
1689
1704
  Description: 'Do not mix named captures and numbered captures in a Regexp literal.'
@@ -1993,6 +2008,23 @@ Lint/UnderscorePrefixedVariableName:
1993
2008
  VersionAdded: '0.21'
1994
2009
  AllowKeywordBlockArguments: false
1995
2010
 
2011
+ Lint/UnexpectedBlockArity:
2012
+ Description: 'Looks for blocks that have fewer arguments that the calling method expects.'
2013
+ Enabled: pending
2014
+ Safe: false
2015
+ VersionAdded: '1.5'
2016
+ Methods:
2017
+ chunk_while: 2
2018
+ each_with_index: 2
2019
+ each_with_object: 2
2020
+ inject: 2
2021
+ max: 2
2022
+ min: 2
2023
+ minmax: 2
2024
+ reduce: 2
2025
+ slice_when: 2
2026
+ sort: 2
2027
+
1996
2028
  Lint/UnifiedInteger:
1997
2029
  Description: 'Use Integer instead of Fixnum or Bignum.'
1998
2030
  Enabled: true
@@ -2002,6 +2034,7 @@ Lint/UnmodifiedReduceAccumulator:
2002
2034
  Description: Checks for `reduce` or `inject` blocks that do not update the accumulator each iteration.
2003
2035
  Enabled: pending
2004
2036
  VersionAdded: '1.1'
2037
+ VersionChanged: '1.5'
2005
2038
 
2006
2039
  Lint/UnreachableCode:
2007
2040
  Description: 'Unreachable code.'
@@ -2105,21 +2138,23 @@ Metrics/AbcSize:
2105
2138
  - https://en.wikipedia.org/wiki/ABC_Software_Metric
2106
2139
  Enabled: true
2107
2140
  VersionAdded: '0.27'
2108
- VersionChanged: '0.81'
2141
+ VersionChanged: '1.5'
2109
2142
  # The ABC size is a calculated magnitude, so this number can be an Integer or
2110
2143
  # a Float.
2111
2144
  IgnoredMethods: []
2145
+ CountRepeatedAttributes: true
2112
2146
  Max: 17
2113
2147
 
2114
2148
  Metrics/BlockLength:
2115
2149
  Description: 'Avoid long blocks with many lines.'
2116
2150
  Enabled: true
2117
2151
  VersionAdded: '0.44'
2118
- VersionChanged: '0.87'
2152
+ VersionChanged: '1.5'
2119
2153
  CountComments: false # count full line comments?
2120
2154
  Max: 25
2121
2155
  CountAsOne: []
2122
- ExcludedMethods:
2156
+ ExcludedMethods: [] # deprecated, retained for backwards compatibility
2157
+ IgnoredMethods:
2123
2158
  # By default, exclude the `#refine` method, as it tends to have larger
2124
2159
  # associated blocks.
2125
2160
  - refine
@@ -2160,11 +2195,12 @@ Metrics/MethodLength:
2160
2195
  StyleGuide: '#short-methods'
2161
2196
  Enabled: true
2162
2197
  VersionAdded: '0.25'
2163
- VersionChanged: '0.87'
2198
+ VersionChanged: '1.5'
2164
2199
  CountComments: false # count full line comments?
2165
2200
  Max: 10
2166
2201
  CountAsOne: []
2167
- ExcludedMethods: []
2202
+ ExcludedMethods: [] # deprecated, retained for backwards compatibility
2203
+ IgnoredMethods: []
2168
2204
 
2169
2205
  Metrics/ModuleLength:
2170
2206
  Description: 'Avoid modules longer than 100 lines of code.'
@@ -2180,8 +2216,10 @@ Metrics/ParameterLists:
2180
2216
  StyleGuide: '#too-many-params'
2181
2217
  Enabled: true
2182
2218
  VersionAdded: '0.25'
2219
+ VersionChanged: '1.5'
2183
2220
  Max: 5
2184
2221
  CountKeywordArgs: true
2222
+ MaxOptionalParameters: 3
2185
2223
 
2186
2224
  Metrics/PerceivedComplexity:
2187
2225
  Description: >-
@@ -2451,7 +2489,7 @@ Naming/VariableNumber:
2451
2489
  StyleGuide: '#snake-case-symbols-methods-vars-with-numbers'
2452
2490
  Enabled: true
2453
2491
  VersionAdded: '0.50'
2454
- VersionChanged: '1.3'
2492
+ VersionChanged: '1.4'
2455
2493
  EnforcedStyle: normalcase
2456
2494
  SupportedStyles:
2457
2495
  - snake_case
@@ -2459,7 +2497,13 @@ Naming/VariableNumber:
2459
2497
  - non_integer
2460
2498
  CheckMethodNames: true
2461
2499
  CheckSymbols: true
2462
- AllowedIdentifiers: []
2500
+ AllowedIdentifiers:
2501
+ - capture3 # Open3.capture3
2502
+ - iso8601 # Time#iso8601
2503
+ - rfc1123_date # CGI.rfc1123_date
2504
+ - rfc822 # Time#rfc822
2505
+ - rfc2822 # Time#rfc2822
2506
+ - rfc3339 # DateTime.rfc3339
2463
2507
 
2464
2508
  #################### Security ##############################
2465
2509
 
@@ -3976,6 +4020,17 @@ Style/RandomWithOffset:
3976
4020
  Enabled: true
3977
4021
  VersionAdded: '0.52'
3978
4022
 
4023
+ Style/RedundantArgument:
4024
+ Description: 'Check for a redundant argument passed to certain methods.'
4025
+ Enabled: pending
4026
+ Safe: false
4027
+ VersionAdded: '1.4'
4028
+ Methods:
4029
+ # Array#join
4030
+ join: ''
4031
+ # String#split
4032
+ split: ' '
4033
+
3979
4034
  Style/RedundantAssignment:
3980
4035
  Description: 'Checks for redundant assignment before returning.'
3981
4036
  Enabled: true
@@ -4246,6 +4301,7 @@ Style/SoleNestedConditional:
4246
4301
  which can be merged into outer conditional node.
4247
4302
  Enabled: true
4248
4303
  VersionAdded: '0.89'
4304
+ VersionChanged: '1.5'
4249
4305
  AllowModifier: false
4250
4306
 
4251
4307
  Style/SpecialGlobalVars:
@@ -4378,7 +4434,7 @@ Style/SymbolProc:
4378
4434
  Enabled: true
4379
4435
  Safe: false
4380
4436
  VersionAdded: '0.26'
4381
- VersionChanged: '0.64'
4437
+ VersionChanged: '1.5'
4382
4438
  # A list of method names to be ignored by the check.
4383
4439
  # The names should be fairly unique, otherwise you'll end up ignoring lots of code.
4384
4440
  IgnoredMethods:
@@ -18,6 +18,7 @@ require_relative 'rubocop/ext/regexp_node'
18
18
  require_relative 'rubocop/ext/regexp_parser'
19
19
 
20
20
  require_relative 'rubocop/core_ext/string'
21
+ require_relative 'rubocop/core_ext/hash'
21
22
  require_relative 'rubocop/ext/processed_source'
22
23
 
23
24
  require_relative 'rubocop/path_util'
@@ -88,6 +89,7 @@ require_relative 'rubocop/cop/mixin/interpolation'
88
89
  require_relative 'rubocop/cop/mixin/line_length_help'
89
90
  require_relative 'rubocop/cop/mixin/match_range'
90
91
  require_relative 'rubocop/cop/metrics/utils/repeated_csend_discount'
92
+ require_relative 'rubocop/cop/metrics/utils/repeated_attribute_discount'
91
93
  require_relative 'rubocop/cop/mixin/method_complexity'
92
94
  require_relative 'rubocop/cop/mixin/method_preference'
93
95
  require_relative 'rubocop/cop/mixin/min_body_length'
@@ -341,6 +343,7 @@ require_relative 'rubocop/cop/lint/to_json'
341
343
  require_relative 'rubocop/cop/lint/top_level_return_with_argument'
342
344
  require_relative 'rubocop/cop/lint/trailing_comma_in_attribute_declaration'
343
345
  require_relative 'rubocop/cop/lint/underscore_prefixed_variable_name'
346
+ require_relative 'rubocop/cop/lint/unexpected_block_arity'
344
347
  require_relative 'rubocop/cop/lint/unified_integer'
345
348
  require_relative 'rubocop/cop/lint/unmodified_reduce_accumulator'
346
349
  require_relative 'rubocop/cop/lint/unreachable_code'
@@ -529,6 +532,7 @@ require_relative 'rubocop/cop/style/preferred_hash_methods'
529
532
  require_relative 'rubocop/cop/style/proc'
530
533
  require_relative 'rubocop/cop/style/raise_args'
531
534
  require_relative 'rubocop/cop/style/random_with_offset'
535
+ require_relative 'rubocop/cop/style/redundant_argument'
532
536
  require_relative 'rubocop/cop/style/redundant_begin'
533
537
  require_relative 'rubocop/cop/style/redundant_capital_w'
534
538
  require_relative 'rubocop/cop/style/redundant_condition'
@@ -645,6 +649,7 @@ require_relative 'rubocop/cli/command/auto_genenerate_config'
645
649
  require_relative 'rubocop/cli/command/execute_runner'
646
650
  require_relative 'rubocop/cli/command/init_dotfile'
647
651
  require_relative 'rubocop/cli/command/show_cops'
652
+ require_relative 'rubocop/cli/command/suggest_extensions'
648
653
  require_relative 'rubocop/cli/command/version'
649
654
  require_relative 'rubocop/config_regeneration'
650
655
  require_relative 'rubocop/options'
@@ -69,10 +69,14 @@ module RuboCop
69
69
  if @options[:auto_gen_config]
70
70
  run_command(:auto_gen_config)
71
71
  else
72
- run_command(:execute_runner)
72
+ run_command(:execute_runner).tap { suggest_extensions }
73
73
  end
74
74
  end
75
75
 
76
+ def suggest_extensions
77
+ run_command(:suggest_extensions)
78
+ end
79
+
76
80
  def validate_options_vs_config
77
81
  if @options[:parallel] &&
78
82
  !@config_store.for_pwd.for_all_cops['UseCache']
@@ -22,12 +22,13 @@ module RuboCop
22
22
  def execute_runner(paths)
23
23
  runner = Runner.new(@options, @config_store)
24
24
 
25
- all_passed = runner.run(paths)
26
- display_warning_summary(runner.warnings)
27
- display_error_summary(runner.errors)
28
- maybe_print_corrected_source
25
+ all_pass_or_excluded = with_redirect do
26
+ all_passed = runner.run(paths)
27
+ display_summary(runner)
28
+ all_passed || @options[:auto_gen_config]
29
+ end
29
30
 
30
- all_pass_or_excluded = all_passed || @options[:auto_gen_config]
31
+ maybe_print_corrected_source
31
32
 
32
33
  if runner.aborting?
33
34
  STATUS_INTERRUPTED
@@ -38,6 +39,25 @@ module RuboCop
38
39
  end
39
40
  end
40
41
 
42
+ def with_redirect
43
+ if @options[:stderr]
44
+ orig_stdout = $stdout.dup
45
+ $stdout.reopen($stderr)
46
+
47
+ result = yield
48
+
49
+ $stdout.reopen(orig_stdout)
50
+ result
51
+ else
52
+ yield
53
+ end
54
+ end
55
+
56
+ def display_summary(runner)
57
+ display_warning_summary(runner.warnings)
58
+ display_error_summary(runner.errors)
59
+ end
60
+
41
61
  def display_warning_summary(warnings)
42
62
  return if warnings.empty?
43
63
 
@@ -69,14 +89,9 @@ module RuboCop
69
89
  # See: https://github.com/rubocop-hq/rubocop/issues/8673
70
90
  return if INTEGRATION_FORMATTERS.include?(@options[:format])
71
91
 
72
- # If we are asked to autocorrect source code read from stdin, the only
73
- # reasonable place to write it is to stdout
74
- # Unfortunately, we also write other information to stdout
75
- # So a delimiter is needed for tools to easily identify where the
76
- # autocorrected source begins
77
92
  return unless @options[:stdin] && @options[:auto_correct]
78
93
 
79
- puts '=' * 20
94
+ (@options[:stderr] ? $stderr : $stdout).puts '=' * 20
80
95
  print @options[:stdin]
81
96
  end
82
97
  end
@@ -0,0 +1,80 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RuboCop
4
+ class CLI
5
+ module Command
6
+ # Run all the selected cops and report the result.
7
+ # @api private
8
+ class SuggestExtensions < Base
9
+ # Combination of short and long formatter names.
10
+ INCLUDED_FORMATTERS = %w[p progress fu fuubar pa pacman].freeze
11
+
12
+ self.command_name = :suggest_extensions
13
+
14
+ def self.dependent_gems
15
+ return [] unless defined?(Bundler)
16
+
17
+ # This only includes gems in Gemfile, not in lockfile
18
+ Bundler.load.dependencies.map(&:name)
19
+ rescue Bundler::GemfileNotFound
20
+ []
21
+ end
22
+
23
+ def run
24
+ return if skip? || extensions.none?
25
+
26
+ puts
27
+ puts 'Tip: Based on detected gems, the following '\
28
+ 'RuboCop extension libraries might be helpful:'
29
+
30
+ extensions.sort.each do |extension|
31
+ puts " * #{extension} (http://github.com/rubocop-hq/#{extension})"
32
+ end
33
+
34
+ puts
35
+ puts 'You can opt out of this message by adding the following to your config '\
36
+ '(see https://docs.rubocop.org/rubocop/extensions.html#extension-suggestions '\
37
+ 'for more options):'
38
+ puts ' AllCops:'
39
+ puts ' SuggestExtensions: false'
40
+
41
+ puts if @options[:display_time]
42
+ end
43
+
44
+ private
45
+
46
+ def skip?
47
+ # Disable outputting the notification:
48
+ # 1. On CI
49
+ # 2. When given RuboCop options that it doesn't make sense for
50
+ # 3. For all formatters except specified in `INCLUDED_FORMATTERS'`
51
+ ENV['CI'] ||
52
+ @options[:only] || @options[:debug] || @options[:list_target_files] || @options[:out] ||
53
+ !INCLUDED_FORMATTERS.include?(current_formatter)
54
+ end
55
+
56
+ def current_formatter
57
+ @options[:format] || @config_store.for_pwd.for_all_cops['DefaultFormatter'] || 'p'
58
+ end
59
+
60
+ def extensions
61
+ return [] unless dependent_gems.any?
62
+
63
+ @extensions ||= begin
64
+ extensions = @config_store.for_pwd.for_all_cops['SuggestExtensions'] || {}
65
+ extensions.select { |_, v| (Array(v) & dependent_gems).any? }.keys - dependent_gems
66
+ end
67
+ end
68
+
69
+ def puts(*args)
70
+ output = (@options[:stderr] ? $stderr : $stdout)
71
+ output.puts(*args)
72
+ end
73
+
74
+ def dependent_gems
75
+ @dependent_gems ||= self.class.dependent_gems
76
+ end
77
+ end
78
+ end
79
+ end
80
+ end
@@ -109,7 +109,7 @@ module RuboCop
109
109
  end
110
110
 
111
111
  merge_with_default(config, config_file).tap do |merged_config|
112
- warn_on_pending_cops(merged_config.pending_cops) unless possible_new_cops?(config)
112
+ warn_on_pending_cops(merged_config.pending_cops) unless possible_new_cops?(merged_config)
113
113
  end
114
114
  end
115
115
 
@@ -92,7 +92,7 @@ module RuboCop
92
92
  keys_appearing_in_both.each do |key|
93
93
  if opts[:unset_nil] && derived_hash[key].nil?
94
94
  result.delete(key)
95
- elsif base_hash[key].is_a?(Hash)
95
+ elsif merge_hashes?(base_hash, derived_hash, key)
96
96
  result[key] = merge(base_hash[key], derived_hash[key], **opts)
97
97
  elsif should_union?(base_hash, key, opts[:inherit_mode])
98
98
  result[key] = base_hash[key] | derived_hash[key]
@@ -164,6 +164,10 @@ module RuboCop
164
164
  inherit_mode['merge'].include?(key)
165
165
  end
166
166
 
167
+ def merge_hashes?(base_hash, derived_hash, key)
168
+ base_hash[key].is_a?(Hash) && derived_hash[key].is_a?(Hash)
169
+ end
170
+
167
171
  def base_configs(path, inherit_from, file)
168
172
  configs = Array(inherit_from).compact.map do |f|
169
173
  ConfigLoader.load_file(inherited_file(path, f, file))
@@ -104,6 +104,7 @@ module RuboCop
104
104
  OBSOLETE_COPS = Hash[*(RENAMED_COPS + MOVED_COPS + REMOVED_COPS +
105
105
  REMOVED_COPS_WITH_REASON + SPLIT_COPS).flatten]
106
106
 
107
+ # Parameters can be deprecated but not disabled by setting `severity: :warning`
107
108
  OBSOLETE_PARAMETERS = [
108
109
  {
109
110
  cops: %w[Layout/SpaceAroundOperators Style/SpaceAroundOperators],
@@ -201,6 +202,12 @@ module RuboCop
201
202
  parameters: 'NameWhitelist',
202
203
  alternative: '`NameWhitelist` has been renamed to ' \
203
204
  '`AllowedMethods`.'
205
+ },
206
+ {
207
+ cops: %w[Metrics/BlockLength Metrics/MethodLength],
208
+ parameters: 'ExcludedMethods',
209
+ alternative: '`ExcludedMethods` has been renamed to `IgnoredMethods`.',
210
+ severity: :warning
204
211
  }
205
212
  ].freeze
206
213
 
@@ -214,8 +221,11 @@ module RuboCop
214
221
  }
215
222
  ].freeze
216
223
 
224
+ attr_reader :warnings
225
+
217
226
  def initialize(config)
218
227
  @config = config
228
+ @warnings = []
219
229
  end
220
230
 
221
231
  def reject_obsolete_cops_and_parameters
@@ -256,9 +266,17 @@ module RuboCop
256
266
  end
257
267
 
258
268
  def obsolete_parameters
259
- OBSOLETE_PARAMETERS.map do |params|
260
- obsolete_parameter_message(params[:cops], params[:parameters],
261
- params[:alternative])
269
+ OBSOLETE_PARAMETERS.collect do |params|
270
+ messages = obsolete_parameter_message(params[:cops], params[:parameters],
271
+ params[:alternative])
272
+
273
+ # Warnings are collected separately and not added to the error message
274
+ if messages && params.fetch(:severity, :error) == :warning
275
+ @warnings.concat(messages)
276
+ next
277
+ end
278
+
279
+ messages
262
280
  end
263
281
  end
264
282