runger_style 4.2.0 → 4.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/Gemfile.lock +2 -2
- data/lib/runger_style/cops/multiline_method_arguments_line_breaks.rb +28 -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: 3fcf57a17841bdd969f7d9ae9acbb93ba7e6ad0b0a0224970e2a04dc1986be30
|
4
|
+
data.tar.gz: c005be68f300885f5203a2eecdf449b9639b5d0ea614f6d47ca0550a206c034d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d7bd2f2e3ba4efb3e9712f50cc9790ae89d0279f21488d11f93eeb43e66022f6ed01580ff535139528f3bf9db20be6de9f4fe5001a7eb79f80c651bd33f48b9f
|
7
|
+
data.tar.gz: b7057672c39e2b8d2c9c3bd9dd7619760f6e62edf42f6820fe68f41af98b7b5c8e00a5037ab293a965e2c2d41547efaa795a93a10bd40f615f14a189d61dca98
|
data/CHANGELOG.md
CHANGED
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.1)
|
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.1)
|
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,43 @@
|
|
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 unless node.multiline?
|
12
|
+
return if node.arguments.size <= 1
|
12
13
|
|
13
|
-
|
14
|
-
|
14
|
+
node.arguments.each_cons(2) do |arg1, arg2|
|
15
|
+
next unless same_line?(arg1, arg2)
|
15
16
|
|
16
|
-
|
17
|
+
separator = separator_range(arg1, arg2)
|
17
18
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
19
|
+
add_offense(separator, message: MSG) do |corrector|
|
20
|
+
base_indent = base_indentation(arg1)
|
21
|
+
replacement = ",\n#{base_indent}"
|
22
|
+
corrector.replace(separator, replacement)
|
23
|
+
end
|
22
24
|
end
|
23
25
|
end
|
24
|
-
end
|
25
26
|
|
26
|
-
|
27
|
+
private
|
27
28
|
|
28
|
-
|
29
|
-
|
30
|
-
|
29
|
+
def same_line?(arg1, arg2)
|
30
|
+
arg1.source_range.last_line == arg2.source_range.first_line
|
31
|
+
end
|
31
32
|
|
32
|
-
|
33
|
-
|
34
|
-
|
33
|
+
def base_indentation(arg)
|
34
|
+
arg.source_range.source_line[/^\s*/]
|
35
|
+
end
|
35
36
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
37
|
+
def separator_range(arg1, arg2)
|
38
|
+
end_pos = arg1.source_range.end.end_pos
|
39
|
+
begin_pos = arg2.source_range.begin.begin_pos
|
40
|
+
range_between(end_pos, begin_pos)
|
41
|
+
end
|
40
42
|
end
|
41
43
|
end
|
data/lib/runger_style/version.rb
CHANGED