Make str variable names longer

- Three characters is the RuboCop limit for parameter names, but more
  descriptive is good.
- Requested in
  https://github.com/Homebrew/brew/pull/14922#pullrequestreview-1330848594,
  but the automerge was too quick for me to get to it.
This commit is contained in:
Issy Long 2023-03-08 15:30:25 +00:00
parent 993768106a
commit 2814d2285a
No known key found for this signature in database
GPG Key ID: 8247C390DADC67D4
2 changed files with 8 additions and 8 deletions

View File

@ -23,8 +23,8 @@ module Homebrew
other =~ @text other =~ @text
end end
def include?(str) def include?(string)
@text.include? str @text.include? string
end end
def to_s def to_s

View File

@ -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(str, width: 172) def format_help_text(string, width: 172)
desc = OPTION_DESC_WIDTH desc = OPTION_DESC_WIDTH
indent = width - desc indent = width - desc
str.gsub(/(?<=\S) *\n(?=\S)/, " ") string.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)