Skip to content

Commit

Permalink
Change nonsense return types to Nil in formatter classes (#10623)
Browse files Browse the repository at this point in the history
  • Loading branch information
oprypin authored Aug 2, 2021
1 parent 32659bc commit 406725d
Show file tree
Hide file tree
Showing 7 changed files with 78 additions and 78 deletions.
20 changes: 10 additions & 10 deletions src/mime/multipart/builder.cr
Original file line number Diff line number Diff line change
Expand Up @@ -41,23 +41,23 @@ module MIME::Multipart
# if `#body_part` is called before this method.
#
# Can be called multiple times to append to the preamble multiple times.
def preamble(string : String)
def preamble(string : String) : Nil
preamble { |io| string.to_s(io) }
end

# Appends *data* to the preamble segment of the multipart message. Throws
# if `#body_part` is called before this method.
#
# Can be called multiple times to append to the preamble multiple times.
def preamble(data : Bytes)
def preamble(data : Bytes) : Nil
preamble { |io| io.write data }
end

# Appends *preamble_io* to the preamble segment of the multipart message.
# Throws if `#body_part` is called before this method.
#
# Can be called multiple times to append to the preamble multiple times.
def preamble(preamble_io : IO)
def preamble(preamble_io : IO) : Nil
preamble { |io| IO.copy(preamble_io, io) }
end

Expand All @@ -74,21 +74,21 @@ module MIME::Multipart
# Appends a body part to the multipart message with the given *headers*
# and *string*. Throws if `#finish` or `#epilogue` is called before this
# method.
def body_part(headers : HTTP::Headers, string : String)
def body_part(headers : HTTP::Headers, string : String) : Nil
body_part_impl(headers) { |io| string.to_s(io) }
end

# Appends a body part to the multipart message with the given *headers*
# and *data*. Throws if `#finish` or `#epilogue` is called before this
# method.
def body_part(headers : HTTP::Headers, data : Bytes)
def body_part(headers : HTTP::Headers, data : Bytes) : Nil
body_part_impl(headers) { |io| io.write data }
end

# Appends a body part to the multipart message with the given *headers*
# and data from *body_io*. Throws if `#finish` or `#epilogue` is called
# before this method.
def body_part(headers : HTTP::Headers, body_io : IO)
def body_part(headers : HTTP::Headers, body_io : IO) : Nil
body_part_impl(headers) { |io| IO.copy(body_io, io) }
end

Expand All @@ -102,7 +102,7 @@ module MIME::Multipart
# Appends a body part to the multipart message with the given *headers*
# and no body data. Throws is `#finish` or `#epilogue` is called before
# this method.
def body_part(headers : HTTP::Headers)
def body_part(headers : HTTP::Headers) : Nil
body_part_impl(headers, empty: true) { }
end

Expand Down Expand Up @@ -131,7 +131,7 @@ module MIME::Multipart
# appended.
#
# Can be called multiple times to append to the epilogue multiple times.
def epilogue(string : String)
def epilogue(string : String) : Nil
epilogue { |io| string.to_s(io) }
end

Expand All @@ -140,7 +140,7 @@ module MIME::Multipart
# appended.
#
# Can be called multiple times to append to the epilogue multiple times.
def epilogue(data : Bytes)
def epilogue(data : Bytes) : Nil
epilogue { |io| io.write data }
end

Expand All @@ -149,7 +149,7 @@ module MIME::Multipart
# been appended.
#
# Can be called multiple times to append to the epilogue multiple times.
def epilogue(epilogue_io : IO)
def epilogue(epilogue_io : IO) : Nil
epilogue { |io| IO.copy(epilogue_io, io) }
end

Expand Down
4 changes: 2 additions & 2 deletions src/option_parser.cr
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ class OptionParser
# before, and the flags registered after the call.
#
# This way, you can group the different options in an easier to read way.
def separator(message = "")
def separator(message = "") : Nil
@flags << message.to_s
end

Expand Down Expand Up @@ -259,7 +259,7 @@ class OptionParser
# Stops the current parse and returns immediately, leaving the remaining flags
# unparsed. This is treated identically to `--` being inserted *behind* the
# current parsed flag.
def stop
def stop : Nil
@stop = true
end

Expand Down
10 changes: 5 additions & 5 deletions src/pretty_print.cr
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class PrettyPrint
end

# Appends a text element.
def text(obj)
def text(obj) : Nil
obj = obj.to_s
width = obj.size
return if width == 0
Expand All @@ -84,7 +84,7 @@ class PrettyPrint
end

# Appends an element that can turn into a newline if necessary.
def breakable(sep = " ")
def breakable(sep = " ") : Nil
width = sep.size
group = @group_stack.last
if group.break?
Expand All @@ -102,7 +102,7 @@ class PrettyPrint

# Similar to `#breakable` except
# the decision to break or not is determined individually.
def fill_breakable(sep = " ")
def fill_breakable(sep = " ") : Nil
group { breakable sep }
end

Expand Down Expand Up @@ -149,7 +149,7 @@ class PrettyPrint
# text ","
# breakable
# ```
def comma
def comma : Nil
text ","
breakable
end
Expand Down Expand Up @@ -249,7 +249,7 @@ class PrettyPrint
@break = false
end

def break
def break : Nil
@break = true
end
end
Expand Down
2 changes: 1 addition & 1 deletion src/string/formatter.cr
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ struct String::Formatter(A)
pad size, flags
end

def char(char)
def char(char) : Nil
@io << char
end

Expand Down
2 changes: 1 addition & 1 deletion src/time.cr
Original file line number Diff line number Diff line change
Expand Up @@ -1113,7 +1113,7 @@ struct Time
#
# Number of seconds decimals can be selected with *fraction_digits*.
# Values accepted are 0 (the default, no decimals), 3 (milliseconds), 6 (microseconds) or 9 (nanoseconds).
def to_rfc3339(io : IO, *, fraction_digits : Int = 0)
def to_rfc3339(io : IO, *, fraction_digits : Int = 0) : Nil
Format::RFC_3339.format(to_utc, io, fraction_digits)
end

Expand Down
10 changes: 5 additions & 5 deletions src/time/format/custom/iso_8601.cr
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
struct Time::Format
module Pattern
def date_time_iso_8601
def date_time_iso_8601 : Nil
year_month_day_iso_8601
char? 'T'
time_iso_8601
end

def time_iso_8601
def time_iso_8601 : Nil
hour_minute_second_iso8601
time_zone_z_or_offset
end
end

struct Parser
def year_month_day_iso_8601
def year_month_day_iso_8601 : Nil
year
extended_format = char? '-'
if current_char == 'W'
Expand Down Expand Up @@ -58,7 +58,7 @@ struct Time::Format
end
end

def hour_minute_second_iso8601
def hour_minute_second_iso8601 : Nil
hour_24_zero_padded
decimal_seconds = Time::SECONDS_PER_HOUR

Expand Down Expand Up @@ -106,7 +106,7 @@ struct Time::Format
end

struct Formatter
def year_month_day_iso_8601
def year_month_day_iso_8601 : Nil
year_month_day
end

Expand Down
Loading

0 comments on commit 406725d

Please sign in to comment.