rubocop: Drop "s" from Naming/MethodParameterName allowlist
- Most usages of this were in the `pretty_duration` method, where "s" is better described as "seconds" since we're calculating a duration. - I also took the executive decision to do the same to "m" which refers to "minutes".
This commit is contained in:
parent
87042c0237
commit
89fb8c78e8
@ -202,7 +202,6 @@ Naming/MethodParameterName:
|
|||||||
"p",
|
"p",
|
||||||
"pr",
|
"pr",
|
||||||
"r",
|
"r",
|
||||||
"s",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
# Both styles are used depending on context,
|
# Both styles are used depending on context,
|
||||||
|
|||||||
@ -192,20 +192,20 @@ module Kernel
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def pretty_duration(s)
|
def pretty_duration(seconds)
|
||||||
s = s.to_i
|
seconds = seconds.to_i
|
||||||
res = +""
|
res = +""
|
||||||
|
|
||||||
if s > 59
|
if seconds > 59
|
||||||
m = s / 60
|
minutes = seconds / 60
|
||||||
s %= 60
|
seconds %= 60
|
||||||
res = +"#{m} #{Utils.pluralize("minute", m)}"
|
res = +"#{minutes} #{Utils.pluralize("minute", minutes)}"
|
||||||
return res.freeze if s.zero?
|
return res.freeze if seconds.zero?
|
||||||
|
|
||||||
res << " "
|
res << " "
|
||||||
end
|
end
|
||||||
|
|
||||||
res << "#{s} #{Utils.pluralize("second", s)}"
|
res << "#{seconds} #{Utils.pluralize("second", seconds)}"
|
||||||
res.freeze
|
res.freeze
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -471,14 +471,14 @@ module Kernel
|
|||||||
# preserving character encoding validity. The returned string will
|
# preserving character encoding validity. The returned string will
|
||||||
# be not much longer than the specified max_bytes, though the exact
|
# be not much longer than the specified max_bytes, though the exact
|
||||||
# shortfall or overrun may vary.
|
# shortfall or overrun may vary.
|
||||||
def truncate_text_to_approximate_size(s, max_bytes, options = {})
|
def truncate_text_to_approximate_size(str, max_bytes, options = {})
|
||||||
front_weight = options.fetch(:front_weight, 0.5)
|
front_weight = options.fetch(:front_weight, 0.5)
|
||||||
raise "opts[:front_weight] must be between 0.0 and 1.0" if front_weight < 0.0 || front_weight > 1.0
|
raise "opts[:front_weight] must be between 0.0 and 1.0" if front_weight < 0.0 || front_weight > 1.0
|
||||||
return s if s.bytesize <= max_bytes
|
return str if str.bytesize <= max_bytes
|
||||||
|
|
||||||
glue = "\n[...snip...]\n"
|
glue = "\n[...snip...]\n"
|
||||||
max_bytes_in = [max_bytes - glue.bytesize, 1].max
|
max_bytes_in = [max_bytes - glue.bytesize, 1].max
|
||||||
bytes = s.dup.force_encoding("BINARY")
|
bytes = str.dup.force_encoding("BINARY")
|
||||||
glue_bytes = glue.encode("BINARY")
|
glue_bytes = glue.encode("BINARY")
|
||||||
n_front_bytes = (max_bytes_in * front_weight).floor
|
n_front_bytes = (max_bytes_in * front_weight).floor
|
||||||
n_back_bytes = max_bytes_in - n_front_bytes
|
n_back_bytes = max_bytes_in - n_front_bytes
|
||||||
|
|||||||
@ -23,8 +23,8 @@ module Homebrew
|
|||||||
other =~ @text
|
other =~ @text
|
||||||
end
|
end
|
||||||
|
|
||||||
def include?(s)
|
def include?(str)
|
||||||
@text.include? s
|
@text.include? str
|
||||||
end
|
end
|
||||||
|
|
||||||
def to_s
|
def to_s
|
||||||
|
|||||||
@ -50,14 +50,14 @@ module Formatter
|
|||||||
# so we always wrap one word before an option.
|
# so we always wrap one word before an option.
|
||||||
# @see https://github.com/Homebrew/brew/pull/12672
|
# @see https://github.com/Homebrew/brew/pull/12672
|
||||||
# @see https://macromates.com/blog/2006/wrapping-text-with-regular-expressions/
|
# @see https://macromates.com/blog/2006/wrapping-text-with-regular-expressions/
|
||||||
def format_help_text(s, width: 172)
|
def format_help_text(str, width: 172)
|
||||||
desc = OPTION_DESC_WIDTH
|
desc = OPTION_DESC_WIDTH
|
||||||
indent = width - desc
|
indent = width - desc
|
||||||
s.gsub(/(?<=\S) *\n(?=\S)/, " ")
|
str.gsub(/(?<=\S) *\n(?=\S)/, " ")
|
||||||
.gsub(/([`>)\]]:) /, "\\1\n ")
|
.gsub(/([`>)\]]:) /, "\\1\n ")
|
||||||
.gsub(/^( +-.+ +(?=\S.{#{desc}}))(.{1,#{desc}})( +|$)(?!-)\n?/, "\\1\\2\n#{" " * indent}")
|
.gsub(/^( +-.+ +(?=\S.{#{desc}}))(.{1,#{desc}})( +|$)(?!-)\n?/, "\\1\\2\n#{" " * indent}")
|
||||||
.gsub(/^( {#{indent}}(?=\S.{#{desc}}))(.{1,#{desc}})( +|$)(?!-)\n?/, "\\1\\2\n#{" " * indent}")
|
.gsub(/^( {#{indent}}(?=\S.{#{desc}}))(.{1,#{desc}})( +|$)(?!-)\n?/, "\\1\\2\n#{" " * indent}")
|
||||||
.gsub(/(.{1,#{width}})( +|$)(?!-)\n?/, "\\1\n")
|
.gsub(/(.{1,#{width}})( +|$)(?!-)\n?/, "\\1\n")
|
||||||
end
|
end
|
||||||
|
|
||||||
def url(string)
|
def url(string)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user