rubocop 1.50.1 → 1.51.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -3
- data/config/default.yml +20 -3
- data/lib/rubocop/config.rb +4 -0
- data/lib/rubocop/config_obsoletion.rb +2 -2
- data/lib/rubocop/cop/base.rb +4 -0
- data/lib/rubocop/cop/correctors/alignment_corrector.rb +1 -1
- data/lib/rubocop/cop/gemspec/deprecated_attribute_assignment.rb +1 -1
- data/lib/rubocop/cop/gemspec/development_dependencies.rb +1 -1
- data/lib/rubocop/cop/internal_affairs/node_matcher_directive.rb +2 -2
- data/lib/rubocop/cop/layout/first_array_element_line_break.rb +25 -34
- data/lib/rubocop/cop/layout/first_hash_element_line_break.rb +7 -19
- data/lib/rubocop/cop/layout/first_method_argument_line_break.rb +42 -52
- data/lib/rubocop/cop/layout/first_method_parameter_line_break.rb +38 -55
- data/lib/rubocop/cop/layout/heredoc_argument_closing_parenthesis.rb +2 -2
- data/lib/rubocop/cop/layout/multiline_array_line_breaks.rb +8 -27
- data/lib/rubocop/cop/layout/multiline_hash_key_line_breaks.rb +7 -26
- data/lib/rubocop/cop/layout/multiline_method_argument_line_breaks.rb +4 -21
- data/lib/rubocop/cop/layout/multiline_method_parameter_line_breaks.rb +6 -30
- data/lib/rubocop/cop/layout/space_inside_block_braces.rb +2 -0
- data/lib/rubocop/cop/lint/ambiguous_block_association.rb +12 -1
- data/lib/rubocop/cop/lint/duplicate_match_pattern.rb +1 -1
- data/lib/rubocop/cop/lint/erb_new_arguments.rb +2 -2
- data/lib/rubocop/cop/lint/incompatible_io_select_with_fiber_scheduler.rb +5 -2
- data/lib/rubocop/cop/lint/lambda_without_literal_block.rb +1 -1
- data/lib/rubocop/cop/lint/numbered_parameter_assignment.rb +2 -2
- data/lib/rubocop/cop/lint/out_of_range_regexp_ref.rb +2 -2
- data/lib/rubocop/cop/lint/redundant_string_coercion.rb +1 -1
- data/lib/rubocop/cop/lint/top_level_return_with_argument.rb +23 -9
- data/lib/rubocop/cop/lint/useless_assignment.rb +56 -1
- data/lib/rubocop/cop/lint/void.rb +62 -6
- data/lib/rubocop/cop/mixin/comments_help.rb +6 -2
- data/lib/rubocop/cop/mixin/space_after_punctuation.rb +1 -1
- data/lib/rubocop/cop/naming/constant_name.rb +1 -1
- data/lib/rubocop/cop/naming/memoized_instance_variable_name.rb +22 -7
- data/lib/rubocop/cop/naming/rescued_exceptions_variable_name.rb +11 -3
- data/lib/rubocop/cop/style/attr.rb +11 -1
- data/lib/rubocop/cop/style/collection_compact.rb +13 -6
- data/lib/rubocop/cop/style/colon_method_call.rb +2 -2
- data/lib/rubocop/cop/style/combinable_loops.rb +26 -6
- data/lib/rubocop/cop/style/conditional_assignment.rb +2 -2
- data/lib/rubocop/cop/style/copyright.rb +5 -2
- data/lib/rubocop/cop/style/documentation.rb +1 -1
- data/lib/rubocop/cop/style/eval_with_location.rb +1 -1
- data/lib/rubocop/cop/style/exact_regexp_match.rb +62 -0
- data/lib/rubocop/cop/style/guard_clause.rb +2 -0
- data/lib/rubocop/cop/style/hash_except.rb +19 -8
- data/lib/rubocop/cop/style/if_inside_else.rb +6 -0
- data/lib/rubocop/cop/style/if_unless_modifier.rb +3 -0
- data/lib/rubocop/cop/style/invertible_unless_condition.rb +9 -5
- data/lib/rubocop/cop/style/percent_literal_delimiters.rb +1 -1
- data/lib/rubocop/cop/style/redundant_fetch_block.rb +6 -4
- data/lib/rubocop/cop/style/redundant_line_continuation.rb +5 -1
- data/lib/rubocop/cop/style/regexp_literal.rb +11 -2
- data/lib/rubocop/cop/style/require_order.rb +9 -4
- data/lib/rubocop/cop/style/semicolon.rb +12 -1
- data/lib/rubocop/cop/style/special_global_vars.rb +2 -2
- data/lib/rubocop/cop/team.rb +1 -1
- data/lib/rubocop/cop/variable_force/assignment.rb +4 -0
- data/lib/rubocop/cop/variable_force/variable_table.rb +2 -2
- data/lib/rubocop/result_cache.rb +1 -1
- data/lib/rubocop/rspec/cop_helper.rb +1 -1
- data/lib/rubocop/target_ruby.rb +3 -2
- data/lib/rubocop/version.rb +3 -3
- data/lib/rubocop.rb +1 -0
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '0863dd1792c6296e51bcdbbc4503423cbc61f66c40a7120b405f4eaf999349be'
|
4
|
+
data.tar.gz: a4998dfeef1e7f82ffac34fb409494859b28afba9ce6bb007f6ca5870a5e371b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1ff6067cf16502e16e5bf6691717f97b5f0cf34bdd03e0d893ee90185af1a26d5622c394b5b586530a9d596f8f92cdff4b5eb351d305fc8a2206906f903c9606
|
7
|
+
data.tar.gz: 2ab3c9a30731adbd8818bfce7fba9f346ac8f66a3b0a52fe2ee65094a7ed580f617fa776664f59df71d6229cf35e3e9ad74a557ec6a760dcbc6d85ae1008a2bb
|
data/README.md
CHANGED
@@ -53,7 +53,7 @@ To prevent an unwanted RuboCop update you might want to use a conservative versi
|
|
53
53
|
in your `Gemfile`:
|
54
54
|
|
55
55
|
```rb
|
56
|
-
gem 'rubocop', '~> 1.
|
56
|
+
gem 'rubocop', '~> 1.51', require: false
|
57
57
|
```
|
58
58
|
|
59
59
|
See [our versioning policy](https://docs.rubocop.org/rubocop/versioning.html) for further details.
|
@@ -75,8 +75,8 @@ You can read a lot more about RuboCop in its [official docs](https://docs.ruboco
|
|
75
75
|
|
76
76
|
RuboCop officially supports the following runtime Ruby implementations:
|
77
77
|
|
78
|
-
* MRI 2.
|
79
|
-
* JRuby 9.
|
78
|
+
* MRI 2.7+
|
79
|
+
* JRuby 9.4+
|
80
80
|
|
81
81
|
Targets Ruby 2.0+ code analysis.
|
82
82
|
|
data/config/default.yml
CHANGED
@@ -140,7 +140,7 @@ AllCops:
|
|
140
140
|
# or gems.locked file. (Although the Ruby version is specified in the Gemfile
|
141
141
|
# or gems.rb file, RuboCop reads the final value from the lock file.) If the
|
142
142
|
# Ruby version is still unresolved, RuboCop will use the oldest officially
|
143
|
-
# supported Ruby version (currently Ruby 2.
|
143
|
+
# supported Ruby version (currently Ruby 2.7).
|
144
144
|
TargetRubyVersion: ~
|
145
145
|
# Determines if a notification for extension libraries should be shown when
|
146
146
|
# rubocop is run. Keys are the name of the extension, and values are an array
|
@@ -154,6 +154,7 @@ AllCops:
|
|
154
154
|
rubocop-rake: [rake]
|
155
155
|
rubocop-graphql: [graphql]
|
156
156
|
rubocop-capybara: [capybara]
|
157
|
+
rubocop-factory_bot: [factory_bot, factory_bot_rails]
|
157
158
|
# Enable/Disable checking the methods extended by Active Support.
|
158
159
|
ActiveSupportExtensionsEnabled: false
|
159
160
|
|
@@ -2343,6 +2344,9 @@ Lint/TopLevelReturnWithArgument:
|
|
2343
2344
|
Description: 'Detects top level return statements with argument.'
|
2344
2345
|
Enabled: true
|
2345
2346
|
VersionAdded: '0.89'
|
2347
|
+
# These codes are `eval`-ed in method and their return values may be used.
|
2348
|
+
Exclude:
|
2349
|
+
- '**/*.jb'
|
2346
2350
|
|
2347
2351
|
Lint/TrailingCommaInAttributeDeclaration:
|
2348
2352
|
Description: 'Checks for trailing commas in attribute declarations.'
|
@@ -2451,6 +2455,8 @@ Lint/UselessAssignment:
|
|
2451
2455
|
StyleGuide: '#underscore-unused-vars'
|
2452
2456
|
Enabled: true
|
2453
2457
|
VersionAdded: '0.11'
|
2458
|
+
VersionChanged: '1.51'
|
2459
|
+
SafeAutoCorrect: false
|
2454
2460
|
|
2455
2461
|
Lint/UselessElseWithoutRescue:
|
2456
2462
|
Description: 'Checks for useless `else` in `begin..end` without `rescue`.'
|
@@ -2942,7 +2948,9 @@ Naming/VariableNumber:
|
|
2942
2948
|
Security/CompoundHash:
|
2943
2949
|
Description: 'When overwriting Object#hash to combine values, prefer delegating to Array#hash over writing a custom implementation.'
|
2944
2950
|
Enabled: pending
|
2951
|
+
Safe: false
|
2945
2952
|
VersionAdded: '1.28'
|
2953
|
+
VersionChanged: '1.51'
|
2946
2954
|
|
2947
2955
|
Security/Eval:
|
2948
2956
|
Description: 'The use of eval represents a serious security risk.'
|
@@ -3515,7 +3523,9 @@ Style/DataInheritance:
|
|
3515
3523
|
Description: 'Checks for inheritance from Data.define.'
|
3516
3524
|
StyleGuide: '#no-extend-data-define'
|
3517
3525
|
Enabled: pending
|
3526
|
+
SafeAutoCorrect: false
|
3518
3527
|
VersionAdded: '1.49'
|
3528
|
+
VersionChanged: '1.51'
|
3519
3529
|
|
3520
3530
|
Style/DateTime:
|
3521
3531
|
Description: 'Use Time over DateTime.'
|
@@ -3706,6 +3716,11 @@ Style/EvenOdd:
|
|
3706
3716
|
VersionAdded: '0.12'
|
3707
3717
|
VersionChanged: '0.29'
|
3708
3718
|
|
3719
|
+
Style/ExactRegexpMatch:
|
3720
|
+
Description: 'Checks for exact regexp match inside Regexp literals.'
|
3721
|
+
Enabled: pending
|
3722
|
+
VersionAdded: '1.51'
|
3723
|
+
|
3709
3724
|
Style/ExpandPathArguments:
|
3710
3725
|
Description: "Use `expand_path(__dir__)` instead of `expand_path('..', __FILE__)`."
|
3711
3726
|
Enabled: true
|
@@ -4067,7 +4082,9 @@ Style/InverseMethods:
|
|
4067
4082
|
Style/InvertibleUnlessCondition:
|
4068
4083
|
Description: 'Favor `if` with inverted condition over `unless`.'
|
4069
4084
|
Enabled: false
|
4085
|
+
Safe: false
|
4070
4086
|
VersionAdded: '1.44'
|
4087
|
+
VersionChanged: '1.50'
|
4071
4088
|
# `InverseMethods` are methods that can be inverted in a `unless` condition.
|
4072
4089
|
# The relationship of inverse methods needs to be defined in both directions.
|
4073
4090
|
# Keys and values both need to be defined as symbols.
|
@@ -4090,8 +4107,6 @@ Style/InvertibleUnlessCondition:
|
|
4090
4107
|
# :blank?: :present?
|
4091
4108
|
# :include?: :exclude?
|
4092
4109
|
# :exclude?: :include?
|
4093
|
-
# :one?: :many?
|
4094
|
-
# :many?: :one?
|
4095
4110
|
|
4096
4111
|
Style/IpAddresses:
|
4097
4112
|
Description: "Don't include literal IP addresses in code."
|
@@ -4622,7 +4637,9 @@ Style/OpenStructUse:
|
|
4622
4637
|
- https://docs.ruby-lang.org/en/3.0.0/OpenStruct.html#class-OpenStruct-label-Caveats
|
4623
4638
|
|
4624
4639
|
Enabled: pending
|
4640
|
+
Safe: false
|
4625
4641
|
VersionAdded: '1.23'
|
4642
|
+
VersionChanged: '1.51'
|
4626
4643
|
|
4627
4644
|
Style/OperatorMethodCall:
|
4628
4645
|
Description: 'Checks for redundant dot before operator method call.'
|
data/lib/rubocop/config.rb
CHANGED
@@ -68,11 +68,11 @@ module RuboCop
|
|
68
68
|
# Cop rules are keyed by the name of the original cop
|
69
69
|
def load_cop_rules(rules)
|
70
70
|
rules.flat_map do |rule_type, data|
|
71
|
-
data.
|
71
|
+
data.filter_map do |cop_name, configuration|
|
72
72
|
next unless configuration # allow configurations to be disabled with `CopName: ~`
|
73
73
|
|
74
74
|
COP_RULE_CLASSES[rule_type].new(@config, cop_name, configuration)
|
75
|
-
end
|
75
|
+
end
|
76
76
|
end
|
77
77
|
end
|
78
78
|
|
data/lib/rubocop/cop/base.rb
CHANGED
@@ -54,7 +54,7 @@ module RuboCop
|
|
54
54
|
def inside_string_ranges(node)
|
55
55
|
return [] unless node.is_a?(Parser::AST::Node)
|
56
56
|
|
57
|
-
node.each_node(:str, :dstr, :xstr).
|
57
|
+
node.each_node(:str, :dstr, :xstr).filter_map { |n| inside_string_range(n) }
|
58
58
|
end
|
59
59
|
|
60
60
|
def inside_string_range(node)
|
@@ -3,7 +3,7 @@
|
|
3
3
|
module RuboCop
|
4
4
|
module Cop
|
5
5
|
module Gemspec
|
6
|
-
# Checks that deprecated
|
6
|
+
# Checks that deprecated attributes are not set in a gemspec file.
|
7
7
|
# Removing deprecated attributes allows the user to receive smaller packed gems.
|
8
8
|
#
|
9
9
|
# @example
|
@@ -75,7 +75,7 @@ module RuboCop
|
|
75
75
|
|
76
76
|
# @!method add_development_dependency?(node)
|
77
77
|
def_node_matcher :add_development_dependency?, <<~PATTERN
|
78
|
-
(send _ :add_development_dependency (str #forbidden_gem? ...))
|
78
|
+
(send _ :add_development_dependency (str #forbidden_gem? ...) _? _?)
|
79
79
|
PATTERN
|
80
80
|
|
81
81
|
# @!method gem?(node)
|
@@ -59,12 +59,12 @@ module RuboCop
|
|
59
59
|
def method_directives(node)
|
60
60
|
comments = processed_source.ast_with_comments[node]
|
61
61
|
|
62
|
-
comments.
|
62
|
+
comments.filter_map do |comment|
|
63
63
|
match = comment.text.match(REGEXP)
|
64
64
|
next unless match
|
65
65
|
|
66
66
|
{ node: comment, method_name: match[:method_name], args: match[:args] }
|
67
|
-
end
|
67
|
+
end
|
68
68
|
end
|
69
69
|
|
70
70
|
def too_many_directives(node)
|
@@ -6,49 +6,40 @@ module RuboCop
|
|
6
6
|
# Checks for a line break before the first element in a
|
7
7
|
# multi-line array.
|
8
8
|
#
|
9
|
-
# @example
|
9
|
+
# @example
|
10
10
|
#
|
11
|
-
#
|
12
|
-
#
|
13
|
-
#
|
11
|
+
# # bad
|
12
|
+
# [ :a,
|
13
|
+
# :b]
|
14
14
|
#
|
15
|
-
#
|
16
|
-
#
|
17
|
-
#
|
18
|
-
#
|
15
|
+
# # good
|
16
|
+
# [
|
17
|
+
# :a,
|
18
|
+
# :b]
|
19
19
|
#
|
20
|
-
#
|
21
|
-
#
|
20
|
+
# # good
|
21
|
+
# [:a, :b]
|
22
22
|
#
|
23
|
-
#
|
24
|
-
# [
|
25
|
-
# :a,
|
26
|
-
# :b]
|
23
|
+
# @example AllowMultilineFinalElement: false (default)
|
27
24
|
#
|
28
|
-
#
|
29
|
-
#
|
30
|
-
#
|
31
|
-
#
|
32
|
-
# }]
|
25
|
+
# # bad
|
26
|
+
# [ :a, {
|
27
|
+
# :b => :c
|
28
|
+
# }]
|
33
29
|
#
|
34
|
-
#
|
30
|
+
# # good
|
31
|
+
# [
|
32
|
+
# :a, {
|
33
|
+
# :b => :c
|
34
|
+
# }]
|
35
35
|
#
|
36
|
-
#
|
37
|
-
# [ :a,
|
38
|
-
# :b]
|
39
|
-
#
|
40
|
-
# # good
|
41
|
-
# [ :a, {
|
42
|
-
# :b => :c
|
43
|
-
# }]
|
36
|
+
# @example AllowMultilineFinalElement: true
|
44
37
|
#
|
45
|
-
#
|
46
|
-
#
|
47
|
-
#
|
48
|
-
#
|
38
|
+
# # good
|
39
|
+
# [:a, {
|
40
|
+
# :b => :c
|
41
|
+
# }]
|
49
42
|
#
|
50
|
-
# # good
|
51
|
-
# [:a, :b]
|
52
43
|
class FirstArrayElementLineBreak < Base
|
53
44
|
include FirstElementLineBreak
|
54
45
|
extend AutoCorrector
|
@@ -6,17 +6,12 @@ module RuboCop
|
|
6
6
|
# Checks for a line break before the first element in a
|
7
7
|
# multi-line hash.
|
8
8
|
#
|
9
|
-
# @example
|
9
|
+
# @example
|
10
10
|
#
|
11
11
|
# # bad
|
12
12
|
# { a: 1,
|
13
13
|
# b: 2}
|
14
14
|
#
|
15
|
-
# # bad
|
16
|
-
# { a: 1, b: {
|
17
|
-
# c: 3
|
18
|
-
# }}
|
19
|
-
#
|
20
15
|
# # good
|
21
16
|
# {
|
22
17
|
# a: 1,
|
@@ -28,11 +23,14 @@ module RuboCop
|
|
28
23
|
# c: 3
|
29
24
|
# }}
|
30
25
|
#
|
31
|
-
# @example AllowMultilineFinalElement:
|
26
|
+
# @example AllowMultilineFinalElement: false (default)
|
32
27
|
#
|
33
28
|
# # bad
|
34
|
-
# { a: 1,
|
35
|
-
#
|
29
|
+
# { a: 1, b: {
|
30
|
+
# c: 3
|
31
|
+
# }}
|
32
|
+
#
|
33
|
+
# @example AllowMultilineFinalElement: true
|
36
34
|
#
|
37
35
|
# # bad
|
38
36
|
# { a: 1,
|
@@ -45,16 +43,6 @@ module RuboCop
|
|
45
43
|
# c: 3
|
46
44
|
# }}
|
47
45
|
#
|
48
|
-
# # good
|
49
|
-
# {
|
50
|
-
# a: 1,
|
51
|
-
# b: 2 }
|
52
|
-
#
|
53
|
-
# # good
|
54
|
-
# {
|
55
|
-
# a: 1, b: {
|
56
|
-
# c: 3
|
57
|
-
# }}
|
58
46
|
class FirstHashElementLineBreak < Base
|
59
47
|
include FirstElementLineBreak
|
60
48
|
extend AutoCorrector
|
@@ -6,73 +6,63 @@ module RuboCop
|
|
6
6
|
# Checks for a line break before the first argument in a
|
7
7
|
# multi-line method call.
|
8
8
|
#
|
9
|
-
# @example
|
10
|
-
#
|
11
|
-
# # bad
|
12
|
-
# method(foo, bar,
|
13
|
-
# baz)
|
14
|
-
#
|
15
|
-
# # bad
|
16
|
-
# method(foo, bar, {
|
17
|
-
# baz: "a",
|
18
|
-
# qux: "b",
|
19
|
-
# })
|
9
|
+
# @example
|
20
10
|
#
|
21
|
-
#
|
22
|
-
#
|
23
|
-
#
|
24
|
-
# baz)
|
11
|
+
# # bad
|
12
|
+
# method(foo, bar,
|
13
|
+
# baz)
|
25
14
|
#
|
26
|
-
#
|
27
|
-
#
|
28
|
-
#
|
29
|
-
#
|
30
|
-
# qux: "b",
|
31
|
-
# })
|
15
|
+
# # good
|
16
|
+
# method(
|
17
|
+
# foo, bar,
|
18
|
+
# baz)
|
32
19
|
#
|
33
20
|
# # ignored
|
34
21
|
# method foo, bar,
|
35
22
|
# baz
|
36
23
|
#
|
37
|
-
# @example AllowMultilineFinalElement:
|
24
|
+
# @example AllowMultilineFinalElement: false (default)
|
25
|
+
#
|
26
|
+
# # bad
|
27
|
+
# method(foo, bar, {
|
28
|
+
# baz: "a",
|
29
|
+
# qux: "b",
|
30
|
+
# })
|
38
31
|
#
|
39
|
-
#
|
40
|
-
#
|
41
|
-
#
|
32
|
+
# # good
|
33
|
+
# method(
|
34
|
+
# foo, bar, {
|
35
|
+
# baz: "a",
|
36
|
+
# qux: "b",
|
37
|
+
# })
|
42
38
|
#
|
43
|
-
#
|
44
|
-
# method(foo,
|
45
|
-
# bar,
|
46
|
-
# {
|
47
|
-
# baz: "a",
|
48
|
-
# qux: "b",
|
49
|
-
# }
|
50
|
-
# )
|
39
|
+
# @example AllowMultilineFinalElement: true
|
51
40
|
#
|
52
|
-
#
|
53
|
-
#
|
41
|
+
# # bad
|
42
|
+
# method(foo,
|
43
|
+
# bar,
|
44
|
+
# {
|
54
45
|
# baz: "a",
|
55
46
|
# qux: "b",
|
56
|
-
# }
|
47
|
+
# }
|
48
|
+
# )
|
57
49
|
#
|
58
|
-
#
|
59
|
-
#
|
60
|
-
#
|
61
|
-
#
|
50
|
+
# # good
|
51
|
+
# method(foo, bar, {
|
52
|
+
# baz: "a",
|
53
|
+
# qux: "b",
|
54
|
+
# })
|
62
55
|
#
|
63
|
-
#
|
64
|
-
#
|
65
|
-
#
|
66
|
-
#
|
67
|
-
#
|
68
|
-
#
|
69
|
-
#
|
70
|
-
#
|
71
|
-
#
|
56
|
+
# # good
|
57
|
+
# method(
|
58
|
+
# foo,
|
59
|
+
# bar,
|
60
|
+
# {
|
61
|
+
# baz: "a",
|
62
|
+
# qux: "b",
|
63
|
+
# }
|
64
|
+
# )
|
72
65
|
#
|
73
|
-
# # ignored
|
74
|
-
# method foo, bar,
|
75
|
-
# baz
|
76
66
|
class FirstMethodArgumentLineBreak < Base
|
77
67
|
include FirstElementLineBreak
|
78
68
|
extend AutoCorrector
|
@@ -6,69 +6,52 @@ module RuboCop
|
|
6
6
|
# Checks for a line break before the first parameter in a
|
7
7
|
# multi-line method parameter definition.
|
8
8
|
#
|
9
|
-
# @example
|
10
|
-
#
|
11
|
-
# # bad
|
12
|
-
# def method(foo, bar,
|
13
|
-
# baz)
|
14
|
-
# do_something
|
15
|
-
# end
|
16
|
-
#
|
17
|
-
# # bad
|
18
|
-
# def method(foo, bar, baz = {
|
19
|
-
# :a => "b",
|
20
|
-
# })
|
21
|
-
# do_something
|
22
|
-
# end
|
9
|
+
# @example
|
23
10
|
#
|
24
|
-
#
|
25
|
-
#
|
26
|
-
#
|
27
|
-
#
|
28
|
-
#
|
29
|
-
# end
|
11
|
+
# # bad
|
12
|
+
# def method(foo, bar,
|
13
|
+
# baz)
|
14
|
+
# do_something
|
15
|
+
# end
|
30
16
|
#
|
31
|
-
#
|
32
|
-
#
|
33
|
-
# foo, bar,
|
34
|
-
#
|
35
|
-
#
|
36
|
-
#
|
37
|
-
# end
|
17
|
+
# # good
|
18
|
+
# def method(
|
19
|
+
# foo, bar,
|
20
|
+
# baz)
|
21
|
+
# do_something
|
22
|
+
# end
|
38
23
|
#
|
39
|
-
#
|
40
|
-
#
|
41
|
-
#
|
42
|
-
#
|
43
|
-
#
|
24
|
+
# # ignored
|
25
|
+
# def method foo,
|
26
|
+
# bar
|
27
|
+
# do_something
|
28
|
+
# end
|
44
29
|
#
|
45
|
-
# @example AllowMultilineFinalElement:
|
30
|
+
# @example AllowMultilineFinalElement: false (default)
|
46
31
|
#
|
47
|
-
#
|
48
|
-
#
|
49
|
-
#
|
50
|
-
#
|
51
|
-
#
|
32
|
+
# # bad
|
33
|
+
# def method(foo, bar, baz = {
|
34
|
+
# :a => "b",
|
35
|
+
# })
|
36
|
+
# do_something
|
37
|
+
# end
|
52
38
|
#
|
53
|
-
#
|
54
|
-
#
|
55
|
-
#
|
56
|
-
#
|
57
|
-
#
|
58
|
-
#
|
39
|
+
# # good
|
40
|
+
# def method(
|
41
|
+
# foo, bar, baz = {
|
42
|
+
# :a => "b",
|
43
|
+
# })
|
44
|
+
# do_something
|
45
|
+
# end
|
59
46
|
#
|
60
|
-
#
|
61
|
-
# def method(
|
62
|
-
# foo, bar,
|
63
|
-
# baz)
|
64
|
-
# do_something
|
65
|
-
# end
|
47
|
+
# @example AllowMultilineFinalElement: true
|
66
48
|
#
|
67
|
-
#
|
68
|
-
#
|
69
|
-
#
|
70
|
-
#
|
71
|
-
#
|
49
|
+
# # good
|
50
|
+
# def method(foo, bar, baz = {
|
51
|
+
# :a => "b",
|
52
|
+
# })
|
53
|
+
# do_something
|
54
|
+
# end
|
72
55
|
#
|
73
56
|
class FirstMethodParameterLineBreak < Base
|
74
57
|
include FirstElementLineBreak
|
@@ -228,9 +228,9 @@ module RuboCop
|
|
228
228
|
end
|
229
229
|
|
230
230
|
def find_most_bottom_of_heredoc_end(arguments)
|
231
|
-
arguments.
|
231
|
+
arguments.filter_map do |argument|
|
232
232
|
argument.loc.heredoc_end.end_pos if argument.loc.respond_to?(:heredoc_end)
|
233
|
-
end.
|
233
|
+
end.max
|
234
234
|
end
|
235
235
|
|
236
236
|
# Internal trailing comma helpers.
|
@@ -6,7 +6,7 @@ module RuboCop
|
|
6
6
|
# Ensures that each item in a multi-line array
|
7
7
|
# starts on a separate line.
|
8
8
|
#
|
9
|
-
# @example
|
9
|
+
# @example
|
10
10
|
#
|
11
11
|
# # bad
|
12
12
|
# [
|
@@ -14,11 +14,6 @@ module RuboCop
|
|
14
14
|
# c
|
15
15
|
# ]
|
16
16
|
#
|
17
|
-
# # bad
|
18
|
-
# [ a, b, foo(
|
19
|
-
# bar
|
20
|
-
# )]
|
21
|
-
#
|
22
17
|
# # good
|
23
18
|
# [
|
24
19
|
# a,
|
@@ -35,34 +30,20 @@ module RuboCop
|
|
35
30
|
# )
|
36
31
|
# ]
|
37
32
|
#
|
38
|
-
# @example AllowMultilineFinalElement:
|
33
|
+
# @example AllowMultilineFinalElement: false (default)
|
39
34
|
#
|
40
35
|
# # bad
|
41
|
-
# [
|
42
|
-
# a, b,
|
43
|
-
# c
|
44
|
-
# ]
|
45
|
-
#
|
46
|
-
# # good
|
47
|
-
# [ a, b, foo(
|
36
|
+
# [a, b, foo(
|
48
37
|
# bar
|
49
38
|
# )]
|
50
39
|
#
|
51
|
-
#
|
52
|
-
# [
|
53
|
-
# a,
|
54
|
-
# b,
|
55
|
-
# c
|
56
|
-
# ]
|
40
|
+
# @example AllowMultilineFinalElement: true
|
57
41
|
#
|
58
42
|
# # good
|
59
|
-
# [
|
60
|
-
#
|
61
|
-
#
|
62
|
-
#
|
63
|
-
# bar
|
64
|
-
# )
|
65
|
-
# ]
|
43
|
+
# [a, b, foo(
|
44
|
+
# bar
|
45
|
+
# )]
|
46
|
+
#
|
66
47
|
class MultilineArrayLineBreaks < Base
|
67
48
|
include MultilineElementLineBreaks
|
68
49
|
extend AutoCorrector
|