rubocop 0.66.0 → 0.67.0

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 (39) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/config/default.yml +75 -26
  4. data/exe/rubocop +12 -0
  5. data/lib/rubocop.rb +12 -5
  6. data/lib/rubocop/cli.rb +11 -9
  7. data/lib/rubocop/config.rb +3 -0
  8. data/lib/rubocop/config_loader_resolver.rb +2 -2
  9. data/lib/rubocop/cop/commissioner.rb +3 -3
  10. data/lib/rubocop/cop/layout/multiline_array_line_breaks.rb +39 -0
  11. data/lib/rubocop/cop/layout/multiline_hash_key_line_breaks.rb +50 -0
  12. data/lib/rubocop/cop/layout/multiline_method_argument_line_breaks.rb +52 -0
  13. data/lib/rubocop/cop/lint/to_json.rb +5 -2
  14. data/lib/rubocop/cop/mixin/multiline_element_line_breaks.rb +33 -0
  15. data/lib/rubocop/cop/mixin/uncommunicative_name.rb +6 -1
  16. data/lib/rubocop/cop/naming/rescued_exceptions_variable_name.rb +76 -0
  17. data/lib/rubocop/cop/rails/active_record_override.rb +67 -0
  18. data/lib/rubocop/cop/rails/blank.rb +6 -0
  19. data/lib/rubocop/cop/rails/lexically_scoped_action_filter.rb +30 -4
  20. data/lib/rubocop/cop/rails/link_to_blank.rb +7 -6
  21. data/lib/rubocop/cop/rails/present.rb +5 -1
  22. data/lib/rubocop/cop/rails/redundant_allow_nil.rb +105 -0
  23. data/lib/rubocop/cop/rails/redundant_receiver_in_with_options.rb +1 -0
  24. data/lib/rubocop/cop/style/block_comments.rb +9 -1
  25. data/lib/rubocop/cop/{performance → style}/redundant_sort_by.rb +1 -1
  26. data/lib/rubocop/cop/{performance → style}/sample.rb +1 -1
  27. data/lib/rubocop/cop/style/stderr_puts.rb +9 -3
  28. data/lib/rubocop/cop/{performance/lstrip_rstrip.rb → style/strip.rb} +2 -2
  29. data/lib/rubocop/cop/style/struct_inheritance.rb +10 -2
  30. data/lib/rubocop/cop/{performance → style}/unneeded_sort.rb +1 -1
  31. data/lib/rubocop/node_pattern.rb +8 -6
  32. data/lib/rubocop/path_util.rb +3 -3
  33. data/lib/rubocop/processed_source.rb +2 -2
  34. data/lib/rubocop/remote_config.rb +6 -4
  35. data/lib/rubocop/result_cache.rb +2 -2
  36. data/lib/rubocop/runner.rb +2 -2
  37. data/lib/rubocop/target_finder.rb +7 -2
  38. data/lib/rubocop/version.rb +1 -1
  39. metadata +29 -7
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7917fb6bc9ad3c4e8e80d2931b7c275f7485ece4bcd0d18be214949e2facb5c6
4
- data.tar.gz: e243620f2c8903c4a71eb755397cb6f0b7094c47202df5bc6310f911ec161557
3
+ metadata.gz: cd2f651847d82c143bc686cdb3f1eb0b8abdf2054ecdc017d0572dfe5a89171e
4
+ data.tar.gz: bc59c6c04526cb7caeb6edd33501442082540408857dc16ed9fa757cc446406b
5
5
  SHA512:
6
- metadata.gz: 398cf3d8e470cdece6665bd91f9960639acc9196989a80bf6189cea39bdc4f3345a3ff11c5073646d9d4c80369d5ae7e5cc132f01e7855940b546b62ea143352
7
- data.tar.gz: bdc1aabc612fb36230023a06d8cb507a95539ecdc42386ac5f608aff02bb0d8a918f1b39412322905fab1bcb58f107296f4a84b2a34c80d64edf302ba8976d06
6
+ metadata.gz: ef9d7cefbb978c4f9430fa5efc0cd9c45ce7e272d618974cce68e8b426df5c115745ebc5b2e3aeeadc892612a743937157473b9399eca40794a61b0f2a489994
7
+ data.tar.gz: 53fa08a90ffc2256b7f667ed9a00892809154192d78d918e8c8db45cd398e2cd156c9b9166c882346035edfc45643d5996dac3b6492e7aae08513b3ec64c43d0
data/README.md CHANGED
@@ -53,7 +53,7 @@ haven't reached version 1.0 yet). To prevent an unwanted RuboCop update you
53
53
  might want to use a conservative version lock in your `Gemfile`:
54
54
 
55
55
  ```rb
56
- gem 'rubocop', '~> 0.66.0', require: false
56
+ gem 'rubocop', '~> 0.67.0', require: false
57
57
  ```
58
58
 
59
59
  ## Quickstart
@@ -368,7 +368,7 @@ Layout/CaseIndentation:
368
368
 
369
369
  Layout/ClassStructure:
370
370
  Description: 'Enforces a configured order of definitions within a class body.'
371
- StyleGuide: 'https://github.com/rubocop-hq/ruby-style-guide#consistent-classes'
371
+ StyleGuide: '#consistent-classes'
372
372
  Enabled: false
373
373
  VersionAdded: '0.52'
374
374
  Categories:
@@ -772,6 +772,13 @@ Layout/MultilineArrayBraceLayout:
772
772
  - new_line
773
773
  - same_line
774
774
 
775
+ Layout/MultilineArrayLineBreaks:
776
+ Description: >-
777
+ Checks that each item in a multi-line array literal
778
+ starts on a separate line.
779
+ Enabled: false
780
+ VersionAdded: '0.67'
781
+
775
782
  Layout/MultilineAssignmentLayout:
776
783
  Description: 'Check for a newline after the assignment operator in multi-line assignments.'
777
784
  StyleGuide: '#indent-conditional-assignment'
@@ -815,6 +822,20 @@ Layout/MultilineHashBraceLayout:
815
822
  - new_line
816
823
  - same_line
817
824
 
825
+ Layout/MultilineHashKeyLineBreaks:
826
+ Description: >-
827
+ Checks that each item in a multi-line hash literal
828
+ starts on a separate line.
829
+ Enabled: false
830
+ VersionAdded: '0.67'
831
+
832
+ Layout/MultilineMethodArgumentLineBreaks:
833
+ Description: >-
834
+ Checks that each argument in a multi-line method call
835
+ starts on a separate line.
836
+ Enabled: false
837
+ VersionAdded: '0.67'
838
+
818
839
  Layout/MultilineMethodCallBraceLayout:
819
840
  Description: >-
820
841
  Checks that the closing brace in a method call is
@@ -1914,6 +1935,12 @@ Naming/PredicateName:
1914
1935
  Exclude:
1915
1936
  - 'spec/**/*'
1916
1937
 
1938
+ Naming/RescuedExceptionsVariableName:
1939
+ Description: 'Use consistent rescued exceptions variables naming.'
1940
+ Enabled: true
1941
+ VersionAdded: '0.67'
1942
+ PreferredName: ex
1943
+
1917
1944
  Naming/UncommunicativeBlockParamName:
1918
1945
  Description: >-
1919
1946
  Checks for block parameter names that contain capital letters,
@@ -2088,11 +2115,6 @@ Performance/InefficientHashSearch:
2088
2115
  VersionAdded: '0.56'
2089
2116
  Safe: false
2090
2117
 
2091
- Performance/LstripRstrip:
2092
- Description: 'Use `strip` instead of `lstrip.rstrip`.'
2093
- Enabled: true
2094
- VersionAdded: '0.36'
2095
-
2096
2118
  Performance/OpenStruct:
2097
2119
  Description: 'Use `Struct` instead of `OpenStruct`.'
2098
2120
  Enabled: false
@@ -2127,11 +2149,6 @@ Performance/RedundantMerge:
2127
2149
  # Max number of key-value pairs to consider an offense
2128
2150
  MaxKeyValuePairs: 2
2129
2151
 
2130
- Performance/RedundantSortBy:
2131
- Description: 'Use `sort` instead of `sort_by { |x| x }`.'
2132
- Enabled: true
2133
- VersionAdded: '0.36'
2134
-
2135
2152
  Performance/RegexpMatch:
2136
2153
  Description: >-
2137
2154
  Use `match?` instead of `Regexp#match`, `String#match`, `Symbol#match`,
@@ -2146,14 +2163,6 @@ Performance/ReverseEach:
2146
2163
  Enabled: true
2147
2164
  VersionAdded: '0.30'
2148
2165
 
2149
- Performance/Sample:
2150
- Description: >-
2151
- Use `sample` instead of `shuffle.first`,
2152
- `shuffle.last`, and `shuffle[Integer]`.
2153
- Reference: 'https://github.com/JuanitoFatas/fast-ruby#arrayshufflefirst-vs-arraysample-code'
2154
- Enabled: true
2155
- VersionAdded: '0.30'
2156
-
2157
2166
  Performance/Size:
2158
2167
  Description: >-
2159
2168
  Use `size` instead of `count` for counting
@@ -2196,13 +2205,6 @@ Performance/UnfreezeString:
2196
2205
  Enabled: true
2197
2206
  VersionAdded: '0.50'
2198
2207
 
2199
- Performance/UnneededSort:
2200
- Description: >-
2201
- Use `min` instead of `sort.first`,
2202
- `max_by` instead of `sort_by...last`, etc.
2203
- Enabled: true
2204
- VersionAdded: '0.55'
2205
-
2206
2208
  Performance/UriDefaultParser:
2207
2209
  Description: 'Use `URI::DEFAULT_PARSER` instead of `URI::Parser.new`.'
2208
2210
  Enabled: true
@@ -2234,6 +2236,15 @@ Rails/ActiveRecordAliases:
2234
2236
  Enabled: true
2235
2237
  VersionAdded: '0.53'
2236
2238
 
2239
+ Rails/ActiveRecordOverride:
2240
+ Description: >-
2241
+ Check for overriding Active Record methods instead of using
2242
+ callbacks.
2243
+ Enabled: true
2244
+ VersionAdded: '0.67'
2245
+ Include:
2246
+ - app/models/**/*.rb
2247
+
2237
2248
  Rails/ActiveSupportAliases:
2238
2249
  Description: >-
2239
2250
  Avoid ActiveSupport aliases of standard ruby methods:
@@ -2270,6 +2281,7 @@ Rails/Blank:
2270
2281
  Description: 'Enforces use of `blank?`.'
2271
2282
  Enabled: true
2272
2283
  VersionAdded: '0.48'
2284
+ VersionChanged: '0.67'
2273
2285
  # Convert usages of `nil? || empty?` to `blank?`
2274
2286
  NilOrEmpty: true
2275
2287
  # Convert usages of `!present?` to `blank?`
@@ -2441,6 +2453,7 @@ Rails/LexicallyScopedActionFilter:
2441
2453
  Description: "Checks that methods specified in the filter's `only` or `except` options are explicitly defined in the controller."
2442
2454
  StyleGuide: 'https://github.com/rubocop-hq/rails-style-guide#lexically-scoped-action-filter'
2443
2455
  Enabled: true
2456
+ Safe: false
2444
2457
  VersionAdded: '0.52'
2445
2458
  Include:
2446
2459
  - app/controllers/**/*.rb
@@ -2488,6 +2501,7 @@ Rails/Present:
2488
2501
  Description: 'Enforces use of `present?`.'
2489
2502
  Enabled: true
2490
2503
  VersionAdded: '0.48'
2504
+ VersionChanged: '0.67'
2491
2505
  # Convert usages of `!nil? && !empty?` to `present?`
2492
2506
  NotNilAndNotEmpty: true
2493
2507
  # Convert usages of `!blank?` to `present?`
@@ -2506,6 +2520,15 @@ Rails/ReadWriteAttribute:
2506
2520
  Include:
2507
2521
  - app/models/**/*.rb
2508
2522
 
2523
+ Rails/RedundantAllowNil:
2524
+ Description: >-
2525
+ Finds redundant use of `allow_nil` when `allow_blank` is set to
2526
+ certain values in model validations.
2527
+ Enabled: true
2528
+ VersionAdded: '0.67'
2529
+ Include:
2530
+ - app/models/**/*.rb
2531
+
2509
2532
  Rails/RedundantReceiverInWithOptions:
2510
2533
  Description: 'Checks for redundant receiver in `with_options`.'
2511
2534
  Enabled: true
@@ -3439,6 +3462,7 @@ Style/MethodCallWithArgsParentheses:
3439
3462
  VersionChanged: '0.61'
3440
3463
  IgnoreMacros: true
3441
3464
  IgnoredMethods: []
3465
+ IncludedMacros: []
3442
3466
  AllowParenthesesInMultilineCall: false
3443
3467
  AllowParenthesesInChaining: false
3444
3468
  AllowParenthesesInCamelCaseMethod: false
@@ -3938,6 +3962,11 @@ Style/RedundantSelf:
3938
3962
  VersionAdded: '0.10'
3939
3963
  VersionChanged: '0.13'
3940
3964
 
3965
+ Style/RedundantSortBy:
3966
+ Description: 'Use `sort` instead of `sort_by { |x| x }`.'
3967
+ Enabled: true
3968
+ VersionAdded: '0.36'
3969
+
3941
3970
  Style/RegexpLiteral:
3942
3971
  Description: 'Use / or %r around regular expressions.'
3943
3972
  StyleGuide: '#percent-r'
@@ -4001,6 +4030,14 @@ Style/SafeNavigation:
4001
4030
  - try
4002
4031
  - try!
4003
4032
 
4033
+ Style/Sample:
4034
+ Description: >-
4035
+ Use `sample` instead of `shuffle.first`,
4036
+ `shuffle.last`, and `shuffle[Integer]`.
4037
+ Reference: 'https://github.com/JuanitoFatas/fast-ruby#arrayshufflefirst-vs-arraysample-code'
4038
+ Enabled: true
4039
+ VersionAdded: '0.30'
4040
+
4004
4041
  Style/SelfAssignment:
4005
4042
  Description: >-
4006
4043
  Checks for places where self-assignment shorthand should have
@@ -4131,6 +4168,11 @@ Style/StringMethods:
4131
4168
  PreferredMethods:
4132
4169
  intern: to_sym
4133
4170
 
4171
+ Style/Strip:
4172
+ Description: 'Use `strip` instead of `lstrip.rstrip`.'
4173
+ Enabled: true
4174
+ VersionAdded: '0.36'
4175
+
4134
4176
  Style/StructInheritance:
4135
4177
  Description: 'Checks for inheritance from Struct.new.'
4136
4178
  StyleGuide: '#no-extend-struct-new'
@@ -4327,6 +4369,13 @@ Style/UnneededPercentQ:
4327
4369
  Enabled: true
4328
4370
  VersionAdded: '0.24'
4329
4371
 
4372
+ Style/UnneededSort:
4373
+ Description: >-
4374
+ Use `min` instead of `sort.first`,
4375
+ `max_by` instead of `sort_by...last`, etc.
4376
+ Enabled: true
4377
+ VersionAdded: '0.55'
4378
+
4330
4379
  Style/UnpackFirst:
4331
4380
  Description: >-
4332
4381
  Checks for accessing the first element of `String#unpack`
@@ -9,6 +9,18 @@ require 'benchmark'
9
9
  cli = RuboCop::CLI.new
10
10
  result = 0
11
11
 
12
+ if defined?(Bundler)
13
+ gemfile_lock = Bundler.read_file(Bundler.default_lockfile)
14
+ parser = Bundler::LockfileParser.new(gemfile_lock)
15
+
16
+ unless parser.dependencies['rubocop-performance']
17
+ warn Rainbow(<<-MESSAGE.strip_indent).yellow.to_s
18
+ [Warn] Performance Cops will be removed from RuboCop 0.68. Use rubocop-performance gem instead.
19
+ https://github.com/rubocop-hq/rubocop/tree/master/manual/migrate_performance_cops.md
20
+ MESSAGE
21
+ end
22
+ end
23
+
12
24
  time = Benchmark.realtime do
13
25
  result = cli.run
14
26
  end
@@ -118,6 +118,7 @@ require_relative 'rubocop/cop/mixin/match_range'
118
118
  require_relative 'rubocop/cop/mixin/method_complexity'
119
119
  require_relative 'rubocop/cop/mixin/method_preference'
120
120
  require_relative 'rubocop/cop/mixin/min_body_length'
121
+ require_relative 'rubocop/cop/mixin/multiline_element_line_breaks'
121
122
  require_relative 'rubocop/cop/mixin/multiline_expression_indentation'
122
123
  require_relative 'rubocop/cop/mixin/multiline_literal_brace_layout'
123
124
  require_relative 'rubocop/cop/mixin/negative_conditional'
@@ -219,9 +220,12 @@ require_relative 'rubocop/cop/layout/initial_indentation'
219
220
  require_relative 'rubocop/cop/layout/leading_blank_lines'
220
221
  require_relative 'rubocop/cop/layout/leading_comment_space'
221
222
  require_relative 'rubocop/cop/layout/multiline_array_brace_layout'
223
+ require_relative 'rubocop/cop/layout/multiline_array_line_breaks'
222
224
  require_relative 'rubocop/cop/layout/multiline_assignment_layout'
223
225
  require_relative 'rubocop/cop/layout/multiline_block_layout'
224
226
  require_relative 'rubocop/cop/layout/multiline_hash_brace_layout'
227
+ require_relative 'rubocop/cop/layout/multiline_hash_key_line_breaks'
228
+ require_relative 'rubocop/cop/layout/multiline_method_argument_line_breaks'
225
229
  require_relative 'rubocop/cop/layout/multiline_method_call_brace_layout'
226
230
  require_relative 'rubocop/cop/layout/multiline_method_call_indentation'
227
231
  require_relative 'rubocop/cop/layout/multiline_method_definition_brace_layout'
@@ -359,6 +363,7 @@ require_relative 'rubocop/cop/naming/memoized_instance_variable_name'
359
363
  require_relative 'rubocop/cop/naming/method_name'
360
364
  require_relative 'rubocop/cop/naming/binary_operator_parameter_name'
361
365
  require_relative 'rubocop/cop/naming/predicate_name'
366
+ require_relative 'rubocop/cop/naming/rescued_exceptions_variable_name'
362
367
  require_relative 'rubocop/cop/naming/uncommunicative_block_param_name'
363
368
  require_relative 'rubocop/cop/naming/uncommunicative_method_param_name'
364
369
  require_relative 'rubocop/cop/naming/variable_name'
@@ -374,23 +379,19 @@ require_relative 'rubocop/cop/performance/end_with'
374
379
  require_relative 'rubocop/cop/performance/fixed_size'
375
380
  require_relative 'rubocop/cop/performance/flat_map'
376
381
  require_relative 'rubocop/cop/performance/inefficient_hash_search'
377
- require_relative 'rubocop/cop/performance/lstrip_rstrip'
378
382
  require_relative 'rubocop/cop/performance/open_struct'
379
383
  require_relative 'rubocop/cop/performance/range_include'
380
384
  require_relative 'rubocop/cop/performance/redundant_block_call'
381
385
  require_relative 'rubocop/cop/performance/redundant_match'
382
386
  require_relative 'rubocop/cop/performance/redundant_merge'
383
- require_relative 'rubocop/cop/performance/redundant_sort_by'
384
387
  require_relative 'rubocop/cop/performance/regexp_match'
385
388
  require_relative 'rubocop/cop/performance/reverse_each'
386
- require_relative 'rubocop/cop/performance/sample'
387
389
  require_relative 'rubocop/cop/performance/size'
388
390
  require_relative 'rubocop/cop/performance/compare_with_block'
389
391
  require_relative 'rubocop/cop/performance/start_with'
390
392
  require_relative 'rubocop/cop/performance/string_replacement'
391
393
  require_relative 'rubocop/cop/performance/times_map'
392
394
  require_relative 'rubocop/cop/performance/unfreeze_string'
393
- require_relative 'rubocop/cop/performance/unneeded_sort'
394
395
  require_relative 'rubocop/cop/performance/uri_default_parser'
395
396
  require_relative 'rubocop/cop/performance/chain_array_allocation'
396
397
 
@@ -505,17 +506,19 @@ require_relative 'rubocop/cop/style/proc'
505
506
  require_relative 'rubocop/cop/style/raise_args'
506
507
  require_relative 'rubocop/cop/style/random_with_offset'
507
508
  require_relative 'rubocop/cop/style/redundant_begin'
509
+ require_relative 'rubocop/cop/style/redundant_conditional'
508
510
  require_relative 'rubocop/cop/style/redundant_exception'
509
511
  require_relative 'rubocop/cop/style/redundant_freeze'
510
512
  require_relative 'rubocop/cop/style/redundant_parentheses'
511
513
  require_relative 'rubocop/cop/style/redundant_return'
512
514
  require_relative 'rubocop/cop/style/redundant_self'
513
- require_relative 'rubocop/cop/style/redundant_conditional'
515
+ require_relative 'rubocop/cop/style/redundant_sort_by'
514
516
  require_relative 'rubocop/cop/style/regexp_literal'
515
517
  require_relative 'rubocop/cop/style/rescue_modifier'
516
518
  require_relative 'rubocop/cop/style/rescue_standard_error'
517
519
  require_relative 'rubocop/cop/style/return_nil'
518
520
  require_relative 'rubocop/cop/style/safe_navigation'
521
+ require_relative 'rubocop/cop/style/sample'
519
522
  require_relative 'rubocop/cop/style/self_assignment'
520
523
  require_relative 'rubocop/cop/style/semicolon'
521
524
  require_relative 'rubocop/cop/style/send'
@@ -529,6 +532,7 @@ require_relative 'rubocop/cop/style/string_hash_keys'
529
532
  require_relative 'rubocop/cop/style/string_literals'
530
533
  require_relative 'rubocop/cop/style/string_literals_in_interpolation'
531
534
  require_relative 'rubocop/cop/style/string_methods'
535
+ require_relative 'rubocop/cop/style/strip'
532
536
  require_relative 'rubocop/cop/style/struct_inheritance'
533
537
  require_relative 'rubocop/cop/style/symbol_array'
534
538
  require_relative 'rubocop/cop/style/symbol_literal'
@@ -548,6 +552,7 @@ require_relative 'rubocop/cop/style/unneeded_capital_w'
548
552
  require_relative 'rubocop/cop/style/unneeded_condition'
549
553
  require_relative 'rubocop/cop/style/unneeded_interpolation'
550
554
  require_relative 'rubocop/cop/style/unneeded_percent_q'
555
+ require_relative 'rubocop/cop/style/unneeded_sort'
551
556
  require_relative 'rubocop/cop/style/unpack_first'
552
557
  require_relative 'rubocop/cop/style/variable_interpolation'
553
558
  require_relative 'rubocop/cop/style/when_then'
@@ -559,6 +564,7 @@ require_relative 'rubocop/cop/style/zero_length_predicate'
559
564
 
560
565
  require_relative 'rubocop/cop/rails/action_filter'
561
566
  require_relative 'rubocop/cop/rails/active_record_aliases'
567
+ require_relative 'rubocop/cop/rails/active_record_override'
562
568
  require_relative 'rubocop/cop/rails/active_support_aliases'
563
569
  require_relative 'rubocop/cop/rails/application_job'
564
570
  require_relative 'rubocop/cop/rails/application_record'
@@ -592,6 +598,7 @@ require_relative 'rubocop/cop/rails/pluralization_grammar'
592
598
  require_relative 'rubocop/cop/rails/presence'
593
599
  require_relative 'rubocop/cop/rails/present'
594
600
  require_relative 'rubocop/cop/rails/read_write_attribute'
601
+ require_relative 'rubocop/cop/rails/redundant_allow_nil'
595
602
  require_relative 'rubocop/cop/rails/redundant_receiver_in_with_options'
596
603
  require_relative 'rubocop/cop/rails/reflection_class_name'
597
604
  require_relative 'rubocop/cop/rails/refute_methods'
@@ -45,21 +45,23 @@ module RuboCop
45
45
  act_on_options
46
46
  apply_default_formatter
47
47
  execute_runners(paths)
48
- rescue ConfigNotFoundError, IncorrectCopNameError, OptionArgumentError => e
49
- warn e.message
48
+ rescue ConfigNotFoundError,
49
+ IncorrectCopNameError,
50
+ OptionArgumentError => ex
51
+ warn ex.message
50
52
  STATUS_ERROR
51
- rescue RuboCop::Error => e
52
- warn Rainbow("Error: #{e.message}").red
53
+ rescue RuboCop::Error => ex
54
+ warn Rainbow("Error: #{ex.message}").red
53
55
  STATUS_ERROR
54
56
  rescue Finished
55
57
  STATUS_SUCCESS
56
- rescue OptionParser::InvalidOption => e
57
- warn e.message
58
+ rescue OptionParser::InvalidOption => ex
59
+ warn ex.message
58
60
  warn 'For usage information, use --help'
59
61
  STATUS_ERROR
60
- rescue StandardError, SyntaxError, LoadError => e
61
- warn e.message
62
- warn e.backtrace
62
+ rescue StandardError, SyntaxError, LoadError => ex
63
+ warn ex.message
64
+ warn ex.backtrace
63
65
  STATUS_ERROR
64
66
  end
65
67
  # rubocop:enable Metrics/MethodLength, Metrics/AbcSize
@@ -26,6 +26,9 @@ module RuboCop
26
26
  RUBY_VERSION_FILENAME = '.ruby-version'.freeze
27
27
  DEFAULT_RAILS_VERSION = 5.0
28
28
  OBSOLETE_COPS = {
29
+ 'Performance/LstripRstrip' =>
30
+ 'The `Performance/LstripRstrip` cop has been moved ' \
31
+ 'to `Style/Strip`',
29
32
  'Style/FlipFlop' =>
30
33
  'The `Style/FlipFlop` cop has been moved to `Lint/FlipFlop`.',
31
34
  'Style/TrailingComma' =>
@@ -190,9 +190,9 @@ module RuboCop
190
190
  def gem_config_path(gem_name, relative_config_path)
191
191
  spec = Gem::Specification.find_by_name(gem_name)
192
192
  File.join(spec.gem_dir, relative_config_path)
193
- rescue Gem::LoadError => e
193
+ rescue Gem::LoadError => ex
194
194
  raise Gem::LoadError,
195
- "Unable to find gem #{gem_name}; is the gem installed? #{e}"
195
+ "Unable to find gem #{gem_name}; is the gem installed? #{ex}"
196
196
  end
197
197
  end
198
198
  end
@@ -104,14 +104,14 @@ module RuboCop
104
104
  # cops' `#investigate` methods.
105
105
  def with_cop_error_handling(cop, node = nil)
106
106
  yield
107
- rescue StandardError => e
108
- raise e if @options[:raise_error]
107
+ rescue StandardError => ex
108
+ raise ex if @options[:raise_error]
109
109
 
110
110
  if node
111
111
  line = node.first_line
112
112
  column = node.loc.column
113
113
  end
114
- error = CopError.new(e, line, column)
114
+ error = CopError.new(ex, line, column)
115
115
  @errors[cop] << error
116
116
  end
117
117
  end
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RuboCop
4
+ module Cop
5
+ module Layout
6
+ # This cop ensures that each item in a multi-line array
7
+ # starts on a separate line.
8
+ #
9
+ # @example
10
+ #
11
+ # # bad
12
+ # [
13
+ # a, b,
14
+ # c
15
+ # ]
16
+ #
17
+ # # good
18
+ # [
19
+ # a,
20
+ # b,
21
+ # c
22
+ # ]
23
+ class MultilineArrayLineBreaks < Cop
24
+ include MultilineElementLineBreaks
25
+
26
+ MSG = 'Each item in a multi-line array must start ' \
27
+ 'on a separate line.'.freeze
28
+
29
+ def on_array(node)
30
+ check_line_breaks(node, node.children)
31
+ end
32
+
33
+ def autocorrect(node)
34
+ EmptyLineCorrector.insert_before(node)
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end