diff --git a/Library/.rubocop.yml b/Library/.rubocop.yml index 86d7fa2eed..ad7c5f873b 100644 --- a/Library/.rubocop.yml +++ b/Library/.rubocop.yml @@ -202,7 +202,6 @@ Naming/MethodParameterName: "p", "pr", "r", - "s", ] # Both styles are used depending on context, diff --git a/Library/Homebrew/extend/kernel.rb b/Library/Homebrew/extend/kernel.rb index e152d53c69..ab86f7c36b 100644 --- a/Library/Homebrew/extend/kernel.rb +++ b/Library/Homebrew/extend/kernel.rb @@ -192,20 +192,20 @@ module Kernel end end - def pretty_duration(s) - s = s.to_i + def pretty_duration(seconds) + seconds = seconds.to_i res = +"" - if s > 59 - m = s / 60 - s %= 60 - res = +"#{m} #{Utils.pluralize("minute", m)}" - return res.freeze if s.zero? + if seconds > 59 + minutes = seconds / 60 + seconds %= 60 + res = +"#{minutes} #{Utils.pluralize("minute", minutes)}" + return res.freeze if seconds.zero? res << " " end - res << "#{s} #{Utils.pluralize("second", s)}" + res << "#{seconds} #{Utils.pluralize("second", seconds)}" res.freeze end @@ -471,14 +471,14 @@ module Kernel # preserving character encoding validity. The returned string will # be not much longer than the specified max_bytes, though the exact # 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) 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" 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") n_front_bytes = (max_bytes_in * front_weight).floor n_back_bytes = max_bytes_in - n_front_bytes diff --git a/Library/Homebrew/formula_text_auditor.rb b/Library/Homebrew/formula_text_auditor.rb index 5a83ef53f4..23a6eca104 100644 --- a/Library/Homebrew/formula_text_auditor.rb +++ b/Library/Homebrew/formula_text_auditor.rb @@ -23,8 +23,8 @@ module Homebrew other =~ @text end - def include?(s) - @text.include? s + def include?(str) + @text.include? str end def to_s diff --git a/Library/Homebrew/utils/formatter.rb b/Library/Homebrew/utils/formatter.rb index eabd47549a..fedd5fd490 100644 --- a/Library/Homebrew/utils/formatter.rb +++ b/Library/Homebrew/utils/formatter.rb @@ -50,14 +50,14 @@ module Formatter # so we always wrap one word before an option. # @see https://github.com/Homebrew/brew/pull/12672 # @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 indent = width - desc - s.gsub(/(?<=\S) *\n(?=\S)/, " ") - .gsub(/([`>)\]]:) /, "\\1\n ") - .gsub(/^( +-.+ +(?=\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") + str.gsub(/(?<=\S) *\n(?=\S)/, " ") + .gsub(/([`>)\]]:) /, "\\1\n ") + .gsub(/^( +-.+ +(?=\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") end def url(string)