Skip to content

Commit f636364

Browse files
committed
Fix Layout/LineLength code offenses
Signed-off-by: Alexandre Terrasa <alexandre.terrasa@shopify.com>
1 parent c9816d2 commit f636364

5 files changed

Lines changed: 27 additions & 7 deletions

File tree

lib/spoom/rbs.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,12 @@ def class_annotations
3939
def method_annotations
4040
@annotations.select do |annotation|
4141
case annotation.string
42-
when "@abstract", "@final", "@override", "@override(allow_incompatible: true)", "@overridable", "@without_runtime"
42+
when "@abstract",
43+
"@final",
44+
"@override",
45+
"@override(allow_incompatible: true)",
46+
"@overridable",
47+
"@without_runtime"
4348
true
4449
else
4550
false

lib/spoom/sorbet/translate/sorbet_assertions_to_rbs_comments.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,10 @@ def maybe_translate_assertion(node)
7474
Prism::ClassVariableWriteNode, Prism::ClassVariableAndWriteNode, Prism::ClassVariableOperatorWriteNode, Prism::ClassVariableOrWriteNode,
7575
Prism::ConstantWriteNode, Prism::ConstantAndWriteNode, Prism::ConstantOperatorWriteNode, Prism::ConstantOrWriteNode,
7676
Prism::ConstantPathWriteNode, Prism::ConstantPathAndWriteNode, Prism::ConstantPathOperatorWriteNode, Prism::ConstantPathOrWriteNode,
77-
Prism::GlobalVariableWriteNode, Prism::GlobalVariableAndWriteNode, Prism::GlobalVariableOperatorWriteNode, Prism::GlobalVariableOrWriteNode,
78-
Prism::InstanceVariableWriteNode, Prism::InstanceVariableAndWriteNode, Prism::InstanceVariableOperatorWriteNode, Prism::InstanceVariableOrWriteNode,
77+
Prism::GlobalVariableWriteNode, Prism::GlobalVariableAndWriteNode,
78+
Prism::GlobalVariableOperatorWriteNode, Prism::GlobalVariableOrWriteNode,
79+
Prism::InstanceVariableWriteNode, Prism::InstanceVariableAndWriteNode,
80+
Prism::InstanceVariableOperatorWriteNode, Prism::InstanceVariableOrWriteNode,
7981
Prism::LocalVariableWriteNode, Prism::LocalVariableAndWriteNode, Prism::LocalVariableOperatorWriteNode, Prism::LocalVariableOrWriteNode,
8082
Prism::CallAndWriteNode, Prism::CallOperatorWriteNode, Prism::CallOrWriteNode
8183
node.value

lib/spoom/sorbet/translate/sorbet_sigs_to_rbs_comments.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,10 @@ def apply_class_annotation(parent, node)
260260

261261
arg = body.body.first #: as Prism::Node
262262
srb_type = RBI::Type.parse_node(arg)
263-
@rewriter << Source::Insert.new(parent.location.start_offset, "# @requires_ancestor: #{srb_type.rbs_string}\n#{indent}")
263+
@rewriter << Source::Insert.new(
264+
parent.location.start_offset,
265+
"# @requires_ancestor: #{srb_type.rbs_string}\n#{indent}",
266+
)
264267
end
265268

266269
from = adjust_to_line_start(node.location.start_offset)

lib/spoom/source/rewriter.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,8 @@ def initialize(from, to, text)
9292
# @override
9393
#: (Array[Integer]) -> void
9494
def apply(bytes)
95-
raise PositionError, "Position is out of bounds" if from < 0 || to < 0 || from > bytes.size || to > bytes.size || from > to
95+
raise PositionError,
96+
"Position is out of bounds" if from < 0 || to < 0 || from > bytes.size || to > bytes.size || from > to
9697

9798
bytes[from..to] = *text.bytes
9899
end
@@ -125,7 +126,8 @@ def initialize(from, to)
125126
# @override
126127
#: (Array[untyped]) -> void
127128
def apply(bytes)
128-
raise PositionError, "Position is out of bounds" if from < 0 || to < 0 || from > bytes.size || to > bytes.size || from > to
129+
raise PositionError,
130+
"Position is out of bounds" if from < 0 || to < 0 || from > bytes.size || to > bytes.size || from > to
129131

130132
bytes[from..to] = "".bytes
131133
end

test/spoom/cli/srb/assertions_test.rb

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,15 @@ def test_translate_from_rbi_to_rbs_with_options
4242

4343
@project.write!("file.rb", contents)
4444

45-
result = @project.spoom("srb assertions translate --no-color --no-translate-t-let --no-translate-t-cast --no-translate-t-bind --no-translate-t-must --no-translate-t-unsafe")
45+
result = @project.spoom(<<~CMD)
46+
srb assertions translate \
47+
--no-color \
48+
--no-translate-t-let \
49+
--no-translate-t-cast \
50+
--no-translate-t-bind \
51+
--no-translate-t-must \
52+
--no-translate-t-unsafe
53+
CMD
4654

4755
assert_empty(result.err)
4856
assert(result.status)

0 commit comments

Comments
 (0)