runger_style 4.2.0 → 4.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/Gemfile.lock +2 -2
- data/lib/runger_style/cops/multiline_method_arguments_line_breaks.rb +33 -26
- data/lib/runger_style/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e07fef8f115633d528bdd3ba1dd11e486ddb30ce5d7de78546d09821340f200d
|
4
|
+
data.tar.gz: 608b9111baa0c4a043e18cba9de3bfb9171016fb3d2154b8ef5e2f175b5542dc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7639738ec440dfa2a8e792f85df5d6bf4b195ae1d633ad11fdc2ebc8add0c2bc341902eda81af1aed06afda378809fbf3c9e153de00d3b28e3275c3ce8712eb6
|
7
|
+
data.tar.gz: 77956254b806844912a1c3047a9b6b339a742d806799820f8997a3300a43764556cbc136bcbb8f53c5a09ccff94dfde79acae30982f3f03a6e642f6c770d970c
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
## v4.2.2 (2025-01-27)
|
2
|
+
- Fix `RungerStyle/MultilineMethodArgumentsLineBreaks` false positives.
|
3
|
+
|
4
|
+
## v4.2.1 (2025-01-27)
|
5
|
+
- Explicitly declare `module RungerStyle` in `RungerStyle/MultilineMethodArgumentsLineBreaks` definition.
|
6
|
+
|
1
7
|
## v4.2.0 (2025-01-27)
|
2
8
|
- Add `RungerStyle/MultilineMethodArgumentsLineBreaks` cop.
|
3
9
|
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
runger_style (4.2.
|
4
|
+
runger_style (4.2.2)
|
5
5
|
prism (>= 0.24.0)
|
6
6
|
rubocop (>= 1.68.0)
|
7
7
|
|
@@ -189,7 +189,7 @@ CHECKSUMS
|
|
189
189
|
rubocop-rspec_rails (2.30.0) sha256=888112e83f9d7ef7ad2397e9d69a0b9614a4bae24f072c399804a180f80c4c46
|
190
190
|
ruby-progressbar (1.13.0) sha256=80fc9c47a9b640d6834e0dc7b3c94c9df37f08cb072b7761e4a71e22cff29b33
|
191
191
|
runger_release_assistant (0.14.0) sha256=7abc5eb1e0f63d8d611691bc21698d2b3b8f148a5f47cacd8dd32c21d16ee9be
|
192
|
-
runger_style (4.2.
|
192
|
+
runger_style (4.2.2)
|
193
193
|
securerandom (0.4.1) sha256=cc5193d414a4341b6e225f0cb4446aceca8e50d5e1888743fac16987638ea0b1
|
194
194
|
slop (4.10.1) sha256=844322b5ffcf17ed4815fdb173b04a20dd82b4fd93e3744c88c8fafea696d9c7
|
195
195
|
stringio (3.1.2) sha256=204f1828f85cdb39d57cac4abc6dc44b04505a223f131587f2e20ae3729ba131
|
@@ -1,41 +1,48 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
3
|
+
module RungerStyle # rubocop:disable Style/ClassAndModuleChildren
|
4
|
+
class MultilineMethodArgumentsLineBreaks < ::RuboCop::Cop::Base
|
5
|
+
extend RuboCop::Cop::AutoCorrector
|
6
|
+
include RuboCop::Cop::RangeHelp
|
6
7
|
|
7
|
-
|
8
|
+
MSG = 'Each argument in a multi-line method call must start on a separate line.'
|
8
9
|
|
9
|
-
|
10
|
-
|
11
|
-
|
10
|
+
def on_send(node)
|
11
|
+
return if node.arguments.size <= 1
|
12
|
+
return unless node.parenthesized?
|
13
|
+
return unless multiline_parentheses?(node)
|
12
14
|
|
13
|
-
|
14
|
-
|
15
|
+
node.arguments.each_cons(2) do |arg1, arg2|
|
16
|
+
next unless same_line?(arg1, arg2)
|
15
17
|
|
16
|
-
|
18
|
+
separator = separator_range(arg1, arg2)
|
17
19
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
20
|
+
add_offense(separator, message: MSG) do |corrector|
|
21
|
+
base_indent = base_indentation(arg1)
|
22
|
+
replacement = ",\n#{base_indent}"
|
23
|
+
corrector.replace(separator, replacement)
|
24
|
+
end
|
22
25
|
end
|
23
26
|
end
|
24
|
-
end
|
25
27
|
|
26
|
-
|
28
|
+
private
|
27
29
|
|
28
|
-
|
29
|
-
|
30
|
-
|
30
|
+
def multiline_parentheses?(node)
|
31
|
+
node.loc.begin.line != node.loc.end.line
|
32
|
+
end
|
31
33
|
|
32
|
-
|
33
|
-
|
34
|
-
|
34
|
+
def same_line?(arg1, arg2)
|
35
|
+
arg1.source_range.last_line == arg2.source_range.first_line
|
36
|
+
end
|
37
|
+
|
38
|
+
def base_indentation(arg)
|
39
|
+
arg.source_range.source_line[/^\s*/]
|
40
|
+
end
|
35
41
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
42
|
+
def separator_range(arg1, arg2)
|
43
|
+
end_pos = arg1.source_range.end.end_pos
|
44
|
+
begin_pos = arg2.source_range.begin.begin_pos
|
45
|
+
range_between(end_pos, begin_pos)
|
46
|
+
end
|
40
47
|
end
|
41
48
|
end
|
data/lib/runger_style/version.rb
CHANGED