Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change nonsense return types to Nil in formatter classes #10623

Merged
merged 3 commits into from
Aug 2, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Change nonsense return types to Nil in formatter classes
  • Loading branch information
oprypin committed Apr 11, 2021
commit eda39e8b9efa5def7e5e32a022ce208b4ecf1b0a
20 changes: 10 additions & 10 deletions src/mime/multipart/builder.cr
Original file line number Diff line number Diff line change
@@ -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) : Symbol
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) : Symbol
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) : Symbol
def preamble(preamble_io : IO) : Nil
preamble { |io| IO.copy(preamble_io, io) }
end

@@ -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) : Symbol
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) : Symbol
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) : Symbol
def body_part(headers : HTTP::Headers, body_io : IO) : Nil
body_part_impl(headers) { |io| IO.copy(body_io, io) }
end

@@ -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) : Symbol
def body_part(headers : HTTP::Headers) : Nil
body_part_impl(headers, empty: true) { }
end

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

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

@@ -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) : Symbol
def epilogue(epilogue_io : IO) : Nil
epilogue { |io| IO.copy(epilogue_io, io) }
end

4 changes: 2 additions & 2 deletions src/option_parser.cr
Original file line number Diff line number Diff line change
@@ -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 = "") : Array(String)
def separator(message = "") : Nil
@flags << message.to_s
end

@@ -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 : Bool
def stop : Nil
@stop = true
end

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

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

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

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

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

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

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

2 changes: 1 addition & 1 deletion src/time.cr
Original file line number Diff line number Diff line change
@@ -1114,7 +1114,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) : IO
def to_rfc3339(io : IO, *, fraction_digits : Int = 0) : Nil
Format::RFC_3339.format(to_utc, io, fraction_digits)
end

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 : Char | Time::Location
def date_time_iso_8601 : Nil
year_month_day_iso_8601
char? 'T'
time_iso_8601
end

def time_iso_8601 : Char | Time::Location
def time_iso_8601 : Nil
hour_minute_second_iso8601
time_zone_z_or_offset
end
end

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

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

@@ -106,7 +106,7 @@ struct Time::Format
end

struct Formatter
def year_month_day_iso_8601 : IO
def year_month_day_iso_8601 : Nil
year_month_day
end

Loading