From e30d5c1981f03c5584e45e3033bf7f516dc1cbc9 Mon Sep 17 00:00:00 2001 From: Michael Miller Date: Sun, 30 May 2021 14:21:42 -0600 Subject: [PATCH] Use multiple << on a single line --- src/spectator/abstract_expression.cr | 8 ++------ src/spectator/context.cr | 4 +--- src/spectator/example.cr | 3 +-- src/spectator/example_group_hook.cr | 6 ++---- src/spectator/example_hook.cr | 6 ++---- src/spectator/example_procsy_hook.cr | 6 ++---- src/spectator/formatting/components/comment.cr | 4 +--- .../formatting/components/result_block.cr | 8 ++------ src/spectator/formatting/components/runtime.cr | 9 +++------ src/spectator/formatting/components/totals.cr | 12 +++--------- src/spectator/formatting/tap_formatter.cr | 16 +++++----------- src/spectator/location.cr | 4 +--- src/spectator/mocks/double.cr | 4 +--- src/spectator/mocks/generic_arguments.cr | 3 +-- src/spectator/mocks/generic_method_stub.cr | 9 ++------- src/spectator/mocks/method_call.cr | 3 +-- src/spectator/mocks/method_stub.cr | 3 +-- src/spectator/mocks/verifying_double.cr | 4 +--- src/spectator/node.cr | 7 ++----- 19 files changed, 34 insertions(+), 85 deletions(-) diff --git a/src/spectator/abstract_expression.cr b/src/spectator/abstract_expression.cr index dc4ba13..7985c16 100644 --- a/src/spectator/abstract_expression.cr +++ b/src/spectator/abstract_expression.cr @@ -36,9 +36,7 @@ module Spectator # This consists of the label (if one is available) and the value. def to_s(io) if (label = @label) - io << label - io << ':' - io << ' ' + io << label << ": " end raw_value.to_s(io) end @@ -47,9 +45,7 @@ module Spectator # This consists of the label (if one is available) and the value. def inspect(io) if (label = @label) - io << label - io << ':' - io << ' ' + io << label << ": " end raw_value.inspect(io) end diff --git a/src/spectator/context.cr b/src/spectator/context.cr index 475f49c..c3213e3 100644 --- a/src/spectator/context.cr +++ b/src/spectator/context.cr @@ -16,9 +16,7 @@ abstract class SpectatorContext # :ditto: def inspect(io) - io << "Context<" - io << self.class - io << '>' + io << "Context<" << self.class << '>' end end diff --git a/src/spectator/example.cr b/src/spectator/example.cr index 34b6061..3cca701 100644 --- a/src/spectator/example.cr +++ b/src/spectator/example.cr @@ -160,8 +160,7 @@ module Spectator # Exposes information about the example useful for debugging. def inspect(io) super - io << ' ' - io << result + io << ' ' << result end # Creates the JSON representation of the example, diff --git a/src/spectator/example_group_hook.cr b/src/spectator/example_group_hook.cr index 85f6898..ef44e8b 100644 --- a/src/spectator/example_group_hook.cr +++ b/src/spectator/example_group_hook.cr @@ -36,13 +36,11 @@ module Spectator io << "example group hook" if (label = @label) - io << ' ' - io << label + io << ' ' << label end if (location = @location) - io << " @ " - io << location + io << " @ " << location end end end diff --git a/src/spectator/example_hook.cr b/src/spectator/example_hook.cr index 1f02445..f57c908 100644 --- a/src/spectator/example_hook.cr +++ b/src/spectator/example_hook.cr @@ -38,13 +38,11 @@ module Spectator io << "example hook" if (label = @label) - io << ' ' - io << label + io << ' ' << label end if (location = @location) - io << " @ " - io << location + io << " @ " << location end end end diff --git a/src/spectator/example_procsy_hook.cr b/src/spectator/example_procsy_hook.cr index 27ccae6..8a64f17 100644 --- a/src/spectator/example_procsy_hook.cr +++ b/src/spectator/example_procsy_hook.cr @@ -43,13 +43,11 @@ module Spectator io << "example hook" if (label = @label) - io << ' ' - io << label + io << ' ' << label end if (location = @location) - io << " @ " - io << location + io << " @ " << location end end end diff --git a/src/spectator/formatting/components/comment.cr b/src/spectator/formatting/components/comment.cr index 3ae5341..b398840 100644 --- a/src/spectator/formatting/components/comment.cr +++ b/src/spectator/formatting/components/comment.cr @@ -17,9 +17,7 @@ module Spectator::Formatting::Components # Writes the comment to the output. def to_s(io) - io << '#' - io << ' ' - io << @content + io << "# " << @content end end end diff --git a/src/spectator/formatting/components/result_block.cr b/src/spectator/formatting/components/result_block.cr index fd5eb5f..8ea7459 100644 --- a/src/spectator/formatting/components/result_block.cr +++ b/src/spectator/formatting/components/result_block.cr @@ -55,18 +55,14 @@ module Spectator::Formatting::Components # Produces the title line. private def title_line(io) line(io) do - io << @index - io << ')' - io << ' ' - io << title + io << @index << ") " << title end end # Produces the subtitle line. private def subtitle_line(io) line(io) do - io << subtitle_label - io << subtitle + io << subtitle_label << subtitle end end diff --git a/src/spectator/formatting/components/runtime.cr b/src/spectator/formatting/components/runtime.cr index 90ef3bf..9f28813 100644 --- a/src/spectator/formatting/components/runtime.cr +++ b/src/spectator/formatting/components/runtime.cr @@ -35,20 +35,17 @@ module Spectator::Formatting::Components # Formats for microseconds. private def format_micro(io, micros) - io << micros.round.to_i - io << " microseconds" + io << micros.round.to_i << " microseconds" end # Formats for milliseconds. private def format_millis(io, millis) - io << millis.round(2) - io << " milliseconds" + io << millis.round(2) << " milliseconds" end # Formats for seconds. private def format_seconds(io, seconds) - io << seconds.round(2) - io << " seconds" + io << seconds.round(2) << " seconds" end # Formats for minutes. diff --git a/src/spectator/formatting/components/totals.cr b/src/spectator/formatting/components/totals.cr index db4edab..5af5c30 100644 --- a/src/spectator/formatting/components/totals.cr +++ b/src/spectator/formatting/components/totals.cr @@ -32,19 +32,13 @@ module Spectator::Formatting::Components # Writes the counts to the output. def to_s(io) - io << @examples - io << " examples, " - io << @failures - io << " failures " + io << @examples << " examples, " << @failures << " failures " if @errors > 1 - io << '(' - io << @errors - io << " errors), " + io << '(' << @errors << " errors), " end - io << @pending - io << " pending" + io << @pending << " pending" end end end diff --git a/src/spectator/formatting/tap_formatter.cr b/src/spectator/formatting/tap_formatter.cr index d060041..fe5392f 100644 --- a/src/spectator/formatting/tap_formatter.cr +++ b/src/spectator/formatting/tap_formatter.cr @@ -24,27 +24,21 @@ module Spectator::Formatting # Invoked after an example completes successfully. def example_passed(notification) - @io << "ok " - @io << @counter - @io << " - " + @io << "ok " << @counter << " - " @io.puts notification.example end # Invoked after an example is skipped or marked as pending. def example_pending(notification) - @io << "not ok " # TODO: Skipped tests should report ok. - @io << @counter - @io << " - " - @io << notification.example - @io << " # TODO " + # TODO: Skipped tests should report ok. + @io << "not ok " << @counter << " - " + @io << notification.example << " # TODO " @io.puts "No reason given" # TODO: Get reason from result. end # Invoked after an example fails. def example_failed(notification) - @io << "not ok " - @io << @counter - @io << " - " + @io << "not ok " << @counter << " - " @io.puts notification.example end diff --git a/src/spectator/location.cr b/src/spectator/location.cr index bf1ac68..986d048 100644 --- a/src/spectator/location.cr +++ b/src/spectator/location.cr @@ -62,9 +62,7 @@ module Spectator # FILE:LINE # ``` def to_s(io) - io << path - io << ':' - io << line + io << path << ':' << line end # Creates the JSON representation of the location. diff --git a/src/spectator/mocks/double.cr b/src/spectator/mocks/double.cr index 9684aed..6768c49 100644 --- a/src/spectator/mocks/double.cr +++ b/src/spectator/mocks/double.cr @@ -124,9 +124,7 @@ module Spectator::Mocks end def to_s(io) - io << "Double(" - io << @spectator_double_name - io << ')' + io << "Double(" << @spectator_double_name << ')' end end end diff --git a/src/spectator/mocks/generic_arguments.cr b/src/spectator/mocks/generic_arguments.cr index 18d4193..156ef27 100644 --- a/src/spectator/mocks/generic_arguments.cr +++ b/src/spectator/mocks/generic_arguments.cr @@ -32,8 +32,7 @@ module Spectator::Mocks end io << ", " unless @args.empty? || @opts.empty? @opts.each_with_index do |key, value, i| - io << key - io << ": " + io << key << ": " value.inspect(io) io << ", " if i < @opts.size - 1 end diff --git a/src/spectator/mocks/generic_method_stub.cr b/src/spectator/mocks/generic_method_stub.cr index db4ff8f..15ef9b4 100644 --- a/src/spectator/mocks/generic_method_stub.cr +++ b/src/spectator/mocks/generic_method_stub.cr @@ -18,14 +18,9 @@ module Spectator::Mocks def to_s(io) super(io) if @args - io << '(' - io << @args - io << ')' + io << '(' << @args << ')' end - io << " : " - io << ReturnType - io << " at " - io << @location + io << " : " << ReturnType << " at " << @location end end end diff --git a/src/spectator/mocks/method_call.cr b/src/spectator/mocks/method_call.cr index f89138f..79b3a8b 100644 --- a/src/spectator/mocks/method_call.cr +++ b/src/spectator/mocks/method_call.cr @@ -7,8 +7,7 @@ module Spectator::Mocks end def to_s(io) - io << '#' - io << @name + io << '#' << @name end end end diff --git a/src/spectator/mocks/method_stub.cr b/src/spectator/mocks/method_stub.cr index 8419501..5dc56b8 100644 --- a/src/spectator/mocks/method_stub.cr +++ b/src/spectator/mocks/method_stub.cr @@ -26,8 +26,7 @@ module Spectator::Mocks end def to_s(io) - io << '#' - io << @name + io << '#' << @name end end end diff --git a/src/spectator/mocks/verifying_double.cr b/src/spectator/mocks/verifying_double.cr index 6c8e157..f7be6e3 100644 --- a/src/spectator/mocks/verifying_double.cr +++ b/src/spectator/mocks/verifying_double.cr @@ -100,9 +100,7 @@ module Spectator::Mocks end def to_s(io) - io << "Double(" - io << T - io << ')' + io << "Double(" << T << ')' end end end diff --git a/src/spectator/node.cr b/src/spectator/node.cr index 7a562e1..d1560c8 100644 --- a/src/spectator/node.cr +++ b/src/spectator/node.cr @@ -55,14 +55,11 @@ module Spectator # Exposes information about the node useful for debugging. def inspect(io) # Full node name. - io << '"' - to_s(io) - io << '"' + io << '"' << self << '"' # Add location if it's available. if (location = self.location) - io << " @ " - io << location + io << " @ " << location end end end