mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
style: use parentheses for assignment in conditions
This commit is contained in:
parent
f9b4b69f27
commit
8e5451df2f
@ -7,10 +7,6 @@ Layout/MultilineMethodCallIndentation:
|
||||
Exclude:
|
||||
- "**/*_spec.rb"
|
||||
|
||||
# TODO: add parentheses for these and remove
|
||||
Lint/AssignmentInCondition:
|
||||
Enabled: false
|
||||
|
||||
# `formula do` uses nested method definitions
|
||||
Lint/NestedMethodDefinition:
|
||||
Exclude:
|
||||
|
@ -696,7 +696,7 @@ module Cask
|
||||
def check_denylist
|
||||
return unless cask.tap
|
||||
return unless cask.tap.official?
|
||||
return unless reason = Denylist.reason(cask.token)
|
||||
return unless (reason = Denylist.reason(cask.token))
|
||||
|
||||
add_error "#{cask.token} is not allowed: #{reason}"
|
||||
end
|
||||
|
@ -39,9 +39,9 @@ module Cask
|
||||
Pathname.glob(path.join("*")).sort.select(&:directory?).map do |path|
|
||||
token = path.basename.to_s
|
||||
|
||||
if tap_path = CaskLoader.tap_paths(token).first
|
||||
if (tap_path = CaskLoader.tap_paths(token).first)
|
||||
CaskLoader::FromTapPathLoader.new(tap_path).load(config: config)
|
||||
elsif caskroom_path = Pathname.glob(path.join(".metadata/*/*/*/*.rb")).first
|
||||
elsif (caskroom_path = Pathname.glob(path.join(".metadata/*/*/*/*.rb")).first)
|
||||
CaskLoader::FromPathLoader.new(caskroom_path).load(config: config)
|
||||
else
|
||||
CaskLoader.load(token, config: config)
|
||||
|
@ -191,7 +191,7 @@ module Cask
|
||||
|
||||
basename = downloader.basename
|
||||
|
||||
if nested_container = @cask.container&.nested
|
||||
if (nested_container = @cask.container&.nested)
|
||||
Dir.mktmpdir do |tmpdir|
|
||||
tmpdir = Pathname(tmpdir)
|
||||
primary_container.extract(to: tmpdir, basename: basename, verbose: verbose?)
|
||||
|
@ -80,7 +80,7 @@ module Homebrew
|
||||
|
||||
version = Version.new(version)
|
||||
|
||||
return false unless formula_name = basename.to_s[/\A(.*?)(?:--.*?)*--?(?:#{Regexp.escape(version)})/, 1]
|
||||
return false unless (formula_name = basename.to_s[/\A(.*?)(?:--.*?)*--?(?:#{Regexp.escape(version)})/, 1])
|
||||
|
||||
formula = begin
|
||||
Formulary.from_rack(HOMEBREW_CELLAR/formula_name)
|
||||
@ -95,7 +95,7 @@ module Homebrew
|
||||
if resource_name == "patch"
|
||||
patch_hashes = formula.stable&.patches&.select(&:external?)&.map(&:resource)&.map(&:version)
|
||||
return true unless patch_hashes&.include?(Checksum.new(version.to_s))
|
||||
elsif resource_name && resource_version = formula.stable&.resources&.dig(resource_name)&.version
|
||||
elsif resource_name && (resource_version = formula.stable&.resources&.dig(resource_name)&.version)
|
||||
return true if resource_version != version
|
||||
elsif version.is_a?(PkgVersion)
|
||||
return true if formula.pkg_version > version
|
||||
@ -111,7 +111,7 @@ module Homebrew
|
||||
end
|
||||
|
||||
def stale_cask?(scrub)
|
||||
return false unless name = basename.to_s[/\A(.*?)--/, 1]
|
||||
return false unless (name = basename.to_s[/\A(.*?)--/, 1])
|
||||
|
||||
cask = begin
|
||||
Cask::CaskLoader.load(name)
|
||||
|
@ -623,7 +623,7 @@ module Homebrew
|
||||
end
|
||||
|
||||
def split_non_options(argv)
|
||||
if sep = argv.index("--")
|
||||
if (sep = argv.index("--"))
|
||||
[argv.take(sep), argv.drop(sep + 1)]
|
||||
else
|
||||
[argv, []]
|
||||
|
@ -227,7 +227,7 @@ module Homebrew
|
||||
def info_formula(f, args:)
|
||||
specs = []
|
||||
|
||||
if stable = f.stable
|
||||
if (stable = f.stable)
|
||||
s = "stable #{stable.version}"
|
||||
s += " (bottled)" if stable.bottled? && f.pour_bottle?
|
||||
specs << s
|
||||
|
@ -264,7 +264,7 @@ module Homebrew
|
||||
end
|
||||
end
|
||||
opoo msg if msg
|
||||
elsif !f.any_version_installed? && old_formula = f.old_installed_formulae.first
|
||||
elsif !f.any_version_installed? && (old_formula = f.old_installed_formulae.first)
|
||||
msg = "#{old_formula.full_name} #{old_formula.any_installed_version} already installed"
|
||||
msg = if !old_formula.linked? && !old_formula.keg_only?
|
||||
<<~EOS
|
||||
|
@ -73,7 +73,7 @@ module Homebrew
|
||||
def search
|
||||
args = search_args.parse
|
||||
|
||||
if package_manager = PACKAGE_MANAGERS.find { |name,| args[:"#{name}?"] }
|
||||
if (package_manager = PACKAGE_MANAGERS.find { |name,| args[:"#{name}?"] })
|
||||
_, url = package_manager
|
||||
exec_browser url.call(URI.encode_www_form_component(args.named.join(" ")))
|
||||
return
|
||||
|
@ -175,7 +175,7 @@ module Commands
|
||||
path = self.path(command)
|
||||
return if path.blank?
|
||||
|
||||
if cmd_parser = Homebrew::CLI::Parser.from_cmd_path(path)
|
||||
if (cmd_parser = Homebrew::CLI::Parser.from_cmd_path(path))
|
||||
cmd_parser.processed_options.map do |short, long, _, desc|
|
||||
[long || short, desc]
|
||||
end
|
||||
@ -198,7 +198,7 @@ module Commands
|
||||
path = self.path(command)
|
||||
return if path.blank?
|
||||
|
||||
if cmd_parser = Homebrew::CLI::Parser.from_cmd_path(path)
|
||||
if (cmd_parser = Homebrew::CLI::Parser.from_cmd_path(path))
|
||||
if short
|
||||
cmd_parser.description.split(".").first
|
||||
else
|
||||
|
@ -167,7 +167,7 @@ module Homebrew
|
||||
return unless command_gets_completions? command
|
||||
|
||||
named_completion_string = ""
|
||||
if types = Commands.named_args_type(command)
|
||||
if (types = Commands.named_args_type(command))
|
||||
named_args_strings, named_args_types = types.partition { |type| type.is_a? String }
|
||||
|
||||
named_args_types.each do |type|
|
||||
@ -221,7 +221,7 @@ module Homebrew
|
||||
conflicts = generate_zsh_option_exclusions(command, opt)
|
||||
"#{conflicts}#{opt}[#{format_description desc}]"
|
||||
end
|
||||
if types = Commands.named_args_type(command)
|
||||
if (types = Commands.named_args_type(command))
|
||||
named_args_strings, named_args_types = types.partition { |type| type.is_a? String }
|
||||
|
||||
named_args_types.each do |type|
|
||||
@ -291,7 +291,7 @@ module Homebrew
|
||||
|
||||
subcommands = []
|
||||
named_args = []
|
||||
if types = Commands.named_args_type(command)
|
||||
if (types = Commands.named_args_type(command))
|
||||
named_args_strings, named_args_types = types.partition { |type| type.is_a? String }
|
||||
|
||||
named_args_types.each do |type|
|
||||
|
@ -16,7 +16,7 @@ module Context
|
||||
end
|
||||
|
||||
def self.current
|
||||
if current_context = Thread.current[:context]
|
||||
if (current_context = Thread.current[:context])
|
||||
return current_context
|
||||
end
|
||||
|
||||
|
@ -254,7 +254,7 @@ module Homebrew
|
||||
def bottle_formula(f, args:)
|
||||
return ofail "Formula not installed or up-to-date: #{f.full_name}" unless f.latest_version_installed?
|
||||
|
||||
unless tap = f.tap
|
||||
unless (tap = f.tap)
|
||||
return ofail "Formula not from core or any installed taps: #{f.full_name}" unless args.force_core_tap?
|
||||
|
||||
tap = CoreTap.instance
|
||||
|
@ -179,7 +179,7 @@ module Homebrew
|
||||
# Check for disallowed formula, or names that shadow aliases,
|
||||
# unless --force is specified.
|
||||
unless args.force?
|
||||
if reason = MissingFormula.disallowed_reason(fc.name)
|
||||
if (reason = MissingFormula.disallowed_reason(fc.name))
|
||||
odie <<~EOS
|
||||
The formula '#{fc.name}' is not allowed to be created.
|
||||
#{reason}
|
||||
|
@ -164,7 +164,7 @@ module Homebrew
|
||||
# preserve existing manpage order
|
||||
cmd_paths.sort_by(&method(:sort_key_for_path))
|
||||
.each do |cmd_path|
|
||||
cmd_man_page_lines = if cmd_parser = CLI::Parser.from_cmd_path(cmd_path)
|
||||
cmd_man_page_lines = if (cmd_parser = CLI::Parser.from_cmd_path(cmd_path))
|
||||
next if cmd_parser.hide_from_man_page
|
||||
|
||||
cmd_parser_manpage_lines(cmd_parser).join
|
||||
|
@ -38,7 +38,7 @@ module Homebrew
|
||||
|
||||
formulae = args.named.to_formulae
|
||||
|
||||
if dir = args.destdir
|
||||
if (dir = args.destdir)
|
||||
unpack_dir = Pathname.new(dir).expand_path
|
||||
unpack_dir.mkpath
|
||||
else
|
||||
|
@ -54,9 +54,9 @@ module Homebrew
|
||||
|
||||
start_commit, end_commit = nil
|
||||
cd HOMEBREW_REPOSITORY do
|
||||
start_commit = if commit = args.commit
|
||||
start_commit = if (commit = args.commit)
|
||||
commit
|
||||
elsif date = args.before
|
||||
elsif (date = args.before)
|
||||
Utils.popen_read("git", "rev-list", "-n1", "--before=#{date}", "origin/master").chomp
|
||||
elsif args.to_tag?
|
||||
tags = Utils.popen_read("git", "tag", "--list", "--sort=-version:refname")
|
||||
|
@ -43,7 +43,7 @@ class DevelopmentTools
|
||||
def clang_version
|
||||
@clang_version ||= begin
|
||||
if (path = locate("clang")) &&
|
||||
build_version = `#{path} --version`[/(?:clang|LLVM) version (\d+\.\d)/, 1]
|
||||
(build_version = `#{path} --version`[/(?:clang|LLVM) version (\d+\.\d)/, 1])
|
||||
Version.new build_version
|
||||
else
|
||||
Version::NULL
|
||||
@ -54,7 +54,7 @@ class DevelopmentTools
|
||||
def clang_build_version
|
||||
@clang_build_version ||= begin
|
||||
if (path = locate("clang")) &&
|
||||
build_version = `#{path} --version`[%r{clang(-| version [^ ]+ \(tags/RELEASE_)(\d{2,})}, 2]
|
||||
(build_version = `#{path} --version`[%r{clang(-| version [^ ]+ \(tags/RELEASE_)(\d{2,})}, 2])
|
||||
Version.new build_version
|
||||
else
|
||||
Version::NULL
|
||||
@ -66,7 +66,7 @@ class DevelopmentTools
|
||||
@llvm_clang_build_version ||= begin
|
||||
path = Formulary.factory("llvm").opt_prefix/"bin/clang"
|
||||
if path.executable? &&
|
||||
build_version = `#{path} --version`[/clang version (\d\.\d\.\d)/, 1]
|
||||
(build_version = `#{path} --version`[/clang version (\d\.\d\.\d)/, 1])
|
||||
Version.new build_version
|
||||
else
|
||||
Version::NULL
|
||||
@ -79,7 +79,7 @@ class DevelopmentTools
|
||||
path = HOMEBREW_PREFIX/"opt/#{CompilerSelector.preferred_gcc}/bin"/cc
|
||||
path = locate(cc) unless path.exist?
|
||||
version = if path &&
|
||||
build_version = `#{path} --version`[/gcc(?:(?:-\d+(?:\.\d)?)? \(.+\))? (\d+\.\d\.\d)/, 1]
|
||||
(build_version = `#{path} --version`[/gcc(?:(?:-\d+(?:\.\d)?)? \(.+\))? (\d+\.\d\.\d)/, 1])
|
||||
Version.new build_version
|
||||
else
|
||||
Version::NULL
|
||||
|
@ -441,11 +441,11 @@ class CurlDownloadStrategy < AbstractFileDownloadStrategy
|
||||
content_disposition_parser = Mechanize::HTTP::ContentDispositionParser.new
|
||||
|
||||
parse_content_disposition = lambda do |line|
|
||||
next unless content_disposition = content_disposition_parser.parse(line.sub(/; *$/, ""), true)
|
||||
next unless (content_disposition = content_disposition_parser.parse(line.sub(/; *$/, ""), true))
|
||||
|
||||
filename = nil
|
||||
|
||||
if filename_with_encoding = content_disposition.parameters["filename*"]
|
||||
if (filename_with_encoding = content_disposition.parameters["filename*"])
|
||||
encoding, encoded_filename = filename_with_encoding.split("''", 2)
|
||||
filename = URI.decode_www_form_component(encoded_filename).encode(encoding) if encoding && encoded_filename
|
||||
end
|
||||
|
@ -453,7 +453,7 @@ class BuildError < RuntimeError
|
||||
if formula.tap && defined?(OS::ISSUES_URL)
|
||||
if formula.tap.official?
|
||||
puts Formatter.error(Formatter.url(OS::ISSUES_URL), label: "READ THIS")
|
||||
elsif issues_url = formula.tap.issues_url
|
||||
elsif (issues_url = formula.tap.issues_url)
|
||||
puts <<~EOS
|
||||
If reporting this issue please do so at (not Homebrew/brew or Homebrew/core):
|
||||
#{Formatter.url(issues_url)}
|
||||
|
@ -2061,7 +2061,7 @@ class Formula
|
||||
|
||||
if verbose_using_dots
|
||||
last_dot = Time.at(0)
|
||||
while buf = rd.gets
|
||||
while (buf = rd.gets)
|
||||
log.puts buf
|
||||
# make sure dots printed with interval of at least 1 min.
|
||||
next unless (Time.now - last_dot) > 60
|
||||
@ -2072,7 +2072,7 @@ class Formula
|
||||
end
|
||||
puts
|
||||
else
|
||||
while buf = rd.gets
|
||||
while (buf = rd.gets)
|
||||
log.puts buf
|
||||
puts buf
|
||||
end
|
||||
|
@ -133,7 +133,7 @@ module Homebrew
|
||||
return
|
||||
end
|
||||
|
||||
if oldname = CoreTap.instance.formula_renames[name]
|
||||
if (oldname = CoreTap.instance.formula_renames[name])
|
||||
problem "'#{name}' is reserved as the old name of #{oldname} in homebrew/core."
|
||||
return
|
||||
end
|
||||
@ -367,10 +367,10 @@ module Homebrew
|
||||
|
||||
return unless DevelopmentTools.curl_handles_most_https_certificates?
|
||||
|
||||
if http_content_problem = curl_check_http_content(homepage,
|
||||
if (http_content_problem = curl_check_http_content(homepage,
|
||||
user_agents: [:browser, :default],
|
||||
check_content: true,
|
||||
strict: @strict)
|
||||
strict: @strict))
|
||||
problem http_content_problem
|
||||
end
|
||||
end
|
||||
@ -472,7 +472,7 @@ module Homebrew
|
||||
|
||||
%w[Stable HEAD].each do |name|
|
||||
spec_name = name.downcase.to_sym
|
||||
next unless spec = formula.send(spec_name)
|
||||
next unless (spec = formula.send(spec_name))
|
||||
|
||||
ra = ResourceAuditor.new(spec, spec_name, online: @online, strict: @strict).audit
|
||||
ra.problems.each do |message|
|
||||
@ -497,7 +497,7 @@ module Homebrew
|
||||
)
|
||||
end
|
||||
|
||||
if stable = formula.stable
|
||||
if (stable = formula.stable)
|
||||
version = stable.version
|
||||
problem "Stable: version (#{version}) is set to a string without a digit" if version.to_s !~ /\d/
|
||||
if version.to_s.start_with?("HEAD")
|
||||
|
@ -575,7 +575,7 @@ class FormulaInstaller
|
||||
formula_deps_map = Dependency.expand(formula)
|
||||
.index_by(&:name)
|
||||
|
||||
while f = formulae.pop
|
||||
while (f = formulae.pop)
|
||||
runtime_requirements = runtime_requirements(f)
|
||||
f.recursive_requirements do |dependent, req|
|
||||
build = effective_build_options_for(dependent)
|
||||
|
@ -467,14 +467,14 @@ module Formulary
|
||||
return FormulaLoader.new(name, path)
|
||||
end
|
||||
|
||||
if newref = CoreTap.instance.formula_renames[ref]
|
||||
if (newref = CoreTap.instance.formula_renames[ref])
|
||||
formula_with_that_oldname = core_path(newref)
|
||||
return FormulaLoader.new(newref, formula_with_that_oldname) if formula_with_that_oldname.file?
|
||||
end
|
||||
|
||||
possible_tap_newname_formulae = []
|
||||
Tap.each do |tap|
|
||||
if newref = tap.formula_renames[ref]
|
||||
if (newref = tap.formula_renames[ref])
|
||||
possible_tap_newname_formulae << "#{tap.name}/#{newref}"
|
||||
end
|
||||
end
|
||||
|
@ -25,7 +25,7 @@ module Homebrew
|
||||
def formula_or_cask_skip(formula_or_cask, livecheckable, full_name: false, verbose: false)
|
||||
formula = formula_or_cask if formula_or_cask.is_a?(Formula)
|
||||
|
||||
if stable_url = formula&.stable&.url
|
||||
if (stable_url = formula&.stable&.url)
|
||||
stable_is_gist = stable_url.match?(%r{https?://gist\.github(?:usercontent)?\.com/}i)
|
||||
stable_from_google_code_archive = stable_url.match?(
|
||||
%r{https?://storage\.googleapis\.com/google-code-archive-downloads/}i,
|
||||
|
@ -61,7 +61,7 @@ module Homebrew
|
||||
|
||||
title = (item > "title").first&.text&.strip
|
||||
|
||||
if match = title&.match(/(\d+(?:\.\d+)*)\s*(\([^)]+\))?\Z/)
|
||||
if (match = title&.match(/(\d+(?:\.\d+)*)\s*(\([^)]+\))?\Z/))
|
||||
short_version ||= match[1]
|
||||
version ||= match[2]
|
||||
end
|
||||
|
@ -29,7 +29,7 @@ class Locale
|
||||
private_constant :LOCALE_REGEX
|
||||
|
||||
def self.parse(string)
|
||||
if locale = try_parse(string)
|
||||
if (locale = try_parse(string))
|
||||
return locale
|
||||
end
|
||||
|
||||
@ -42,12 +42,12 @@ class Locale
|
||||
|
||||
scanner = StringScanner.new(string)
|
||||
|
||||
if language = scanner.scan(LANGUAGE_REGEX)
|
||||
if (language = scanner.scan(LANGUAGE_REGEX))
|
||||
sep = scanner.scan(/-/)
|
||||
return if (sep && scanner.eos?) || (sep.nil? && !scanner.eos?)
|
||||
end
|
||||
|
||||
if region = scanner.scan(REGION_REGEX)
|
||||
if (region = scanner.scan(REGION_REGEX))
|
||||
sep = scanner.scan(/-/)
|
||||
return if (sep && scanner.eos?) || (sep.nil? && !scanner.eos?)
|
||||
end
|
||||
|
@ -138,7 +138,7 @@ class Migrator
|
||||
@new_cellar = HOMEBREW_CELLAR/formula.name
|
||||
@new_cellar_existed = @new_cellar.exist?
|
||||
|
||||
if @old_linked_keg = linked_old_linked_keg
|
||||
if (@old_linked_keg = linked_old_linked_keg)
|
||||
@old_linked_keg_record = old_linked_keg.linked_keg_record if old_linked_keg.linked?
|
||||
@old_opt_record = old_linked_keg.opt_record if old_linked_keg.optlinked?
|
||||
@new_linked_keg_record = HOMEBREW_CELLAR/"#{newname}/#{File.basename(old_linked_keg)}"
|
||||
@ -165,7 +165,7 @@ class Migrator
|
||||
|
||||
new_tap = if old_tap
|
||||
old_tap_user, = old_tap.user
|
||||
if migrate_tap = old_tap.tap_migrations[formula.oldname]
|
||||
if (migrate_tap = old_tap.tap_migrations[formula.oldname])
|
||||
new_tap_user, new_tap_repo = migrate_tap.split("/")
|
||||
"#{new_tap_user}/#{new_tap_repo}"
|
||||
end
|
||||
|
@ -84,7 +84,7 @@ class DATAPatch < EmbeddedPatch
|
||||
line = f.gets
|
||||
break if line.nil? || line =~ /^__END__$/
|
||||
end
|
||||
while line = f.gets
|
||||
while (line = f.gets)
|
||||
data << line
|
||||
end
|
||||
end
|
||||
|
@ -31,12 +31,12 @@ class X11Requirement < Requirement
|
||||
end
|
||||
|
||||
satisfy build_env: false do
|
||||
if which_xorg = which("Xorg")
|
||||
if (which_xorg = which("Xorg"))
|
||||
version = Utils.popen_read(which_xorg, "-version", err: :out)[/X Server (\d+\.\d+\.\d+)/, 1]
|
||||
next true if $CHILD_STATUS.success? && version && Version.new(version) >= min_version
|
||||
end
|
||||
|
||||
if which_xdpyinfo = which("xdpyinfo")
|
||||
if (which_xdpyinfo = which("xdpyinfo"))
|
||||
version = Utils.popen_read(which_xdpyinfo, "-version")[/^xdpyinfo (\d+\.\d+\.\d+)/, 1]
|
||||
next true if $CHILD_STATUS.success? && version && Version.new(version) >= min_xdpyinfo_version
|
||||
end
|
||||
|
@ -105,7 +105,7 @@ module Homebrew
|
||||
# pull request.
|
||||
next if url.match?(%r{^https://dl.bintray.com/homebrew/mirror/})
|
||||
|
||||
if http_content_problem = curl_check_http_content(url, specs: specs)
|
||||
if (http_content_problem = curl_check_http_content(url, specs: specs))
|
||||
problem http_content_problem
|
||||
end
|
||||
elsif strategy <= GitDownloadStrategy
|
||||
|
@ -47,7 +47,7 @@ module RuboCop
|
||||
|
||||
test_calls(test) do |node, params|
|
||||
p1, p2 = params
|
||||
if match = string_content(p1).match(%r{(/usr/local/(s?bin))})
|
||||
if (match = string_content(p1).match(%r{(/usr/local/(s?bin))}))
|
||||
offending_node(p1)
|
||||
problem "use \#{#{match[2]}} instead of #{match[1]} in #{node}" do |corrector|
|
||||
corrector.replace(p1.source_range, p1.source.sub(match[1], "\#{#{match[2]}}"))
|
||||
|
@ -155,7 +155,7 @@ module RuboCop
|
||||
|
||||
# Returns the formula tap.
|
||||
def formula_tap
|
||||
return unless match_obj = @file_path.match(%r{/(homebrew-\w+)/})
|
||||
return unless (match_obj = @file_path.match(%r{/(homebrew-\w+)/}))
|
||||
|
||||
match_obj[1]
|
||||
end
|
||||
|
@ -162,7 +162,7 @@ module RuboCop
|
||||
|
||||
find_instance_method_call(body_node, :build, :without?) do |method|
|
||||
arg = parameters(method).first
|
||||
next unless match = regex_match_group(arg, /^-?-?without-(.*)/)
|
||||
next unless (match = regex_match_group(arg, /^-?-?without-(.*)/))
|
||||
|
||||
problem "Don't duplicate 'without': " \
|
||||
"Use `build.without? \"#{match[1]}\"` to check for \"--without-#{match[1]}\""
|
||||
@ -170,7 +170,7 @@ module RuboCop
|
||||
|
||||
find_instance_method_call(body_node, :build, :with?) do |method|
|
||||
arg = parameters(method).first
|
||||
next unless match = regex_match_group(arg, /^-?-?with-(.*)/)
|
||||
next unless (match = regex_match_group(arg, /^-?-?with-(.*)/))
|
||||
|
||||
problem "Don't duplicate 'with': Use `build.with? \"#{match[1]}\"` to check for \"--with-#{match[1]}\""
|
||||
end
|
||||
@ -258,7 +258,7 @@ module RuboCop
|
||||
|
||||
popen_commands.each do |command|
|
||||
find_instance_method_call(body_node, "Utils", command) do |method|
|
||||
next unless match = regex_match_group(parameters(method).first, /^([^"' ]+)=([^"' ]+)(?: (.*))?$/)
|
||||
next unless (match = regex_match_group(parameters(method).first, /^([^"' ]+)=([^"' ]+)(?: (.*))?$/))
|
||||
|
||||
good_args = "Utils.#{command}({ \"#{match[1]}\" => \"#{match[2]}\" }, \"#{match[3]}\")"
|
||||
|
||||
@ -329,7 +329,7 @@ module RuboCop
|
||||
find_strings(body_node).each do |str|
|
||||
content = string_content(str)
|
||||
|
||||
next unless match = content.match(/^python(@)?(\d\.\d+)$/)
|
||||
next unless (match = content.match(/^python(@)?(\d\.\d+)$/))
|
||||
next if python_version == match[2]
|
||||
|
||||
fix = if match[1]
|
||||
@ -385,7 +385,7 @@ module RuboCop
|
||||
end
|
||||
|
||||
find_instance_method_call(body_node, :man, :+) do |method|
|
||||
next unless match = regex_match_group(parameters(method).first, /^man[1-8]$/)
|
||||
next unless (match = regex_match_group(parameters(method).first, /^man[1-8]$/))
|
||||
|
||||
problem "\"#{method.source}\" should be \"#{match[0]}\""
|
||||
end
|
||||
@ -393,37 +393,37 @@ module RuboCop
|
||||
# Avoid hard-coding compilers
|
||||
find_every_method_call_by_name(body_node, :system).each do |method|
|
||||
param = parameters(method).first
|
||||
if match = regex_match_group(param, %r{^(/usr/bin/)?(gcc|llvm-gcc|clang)(\s|$)})
|
||||
if (match = regex_match_group(param, %r{^(/usr/bin/)?(gcc|llvm-gcc|clang)(\s|$)}))
|
||||
problem "Use \"\#{ENV.cc}\" instead of hard-coding \"#{match[2]}\""
|
||||
elsif match = regex_match_group(param, %r{^(/usr/bin/)?((g|llvm-g|clang)\+\+)(\s|$)})
|
||||
elsif (match = regex_match_group(param, %r{^(/usr/bin/)?((g|llvm-g|clang)\+\+)(\s|$)}))
|
||||
problem "Use \"\#{ENV.cxx}\" instead of hard-coding \"#{match[2]}\""
|
||||
end
|
||||
end
|
||||
|
||||
find_instance_method_call(body_node, "ENV", :[]=) do |method|
|
||||
param = parameters(method)[1]
|
||||
if match = regex_match_group(param, %r{^(/usr/bin/)?(gcc|llvm-gcc|clang)(\s|$)})
|
||||
if (match = regex_match_group(param, %r{^(/usr/bin/)?(gcc|llvm-gcc|clang)(\s|$)}))
|
||||
problem "Use \"\#{ENV.cc}\" instead of hard-coding \"#{match[2]}\""
|
||||
elsif match = regex_match_group(param, %r{^(/usr/bin/)?((g|llvm-g|clang)\+\+)(\s|$)})
|
||||
elsif (match = regex_match_group(param, %r{^(/usr/bin/)?((g|llvm-g|clang)\+\+)(\s|$)}))
|
||||
problem "Use \"\#{ENV.cxx}\" instead of hard-coding \"#{match[2]}\""
|
||||
end
|
||||
end
|
||||
|
||||
# Prefer formula path shortcuts in strings
|
||||
formula_path_strings(body_node, :share) do |p|
|
||||
next unless match = regex_match_group(p, %r{^(/(man))/?})
|
||||
next unless (match = regex_match_group(p, %r{^(/(man))/?}))
|
||||
|
||||
problem "\"\#{share}#{match[1]}\" should be \"\#{#{match[2]}}\""
|
||||
end
|
||||
|
||||
formula_path_strings(body_node, :prefix) do |p|
|
||||
if match = regex_match_group(p, %r{^(/share/(info|man))$})
|
||||
if (match = regex_match_group(p, %r{^(/share/(info|man))$}))
|
||||
problem "\"\#\{prefix}#{match[1]}\" should be \"\#{#{match[2]}}\""
|
||||
end
|
||||
if match = regex_match_group(p, %r{^((/share/man/)(man[1-8]))})
|
||||
if (match = regex_match_group(p, %r{^((/share/man/)(man[1-8]))}))
|
||||
problem "\"\#\{prefix}#{match[1]}\" should be \"\#{#{match[3]}}\""
|
||||
end
|
||||
if match = regex_match_group(p, %r{^(/(bin|include|libexec|lib|sbin|share|Frameworks))}i)
|
||||
if (match = regex_match_group(p, %r{^(/(bin|include|libexec|lib|sbin|share|Frameworks))}i))
|
||||
problem "\"\#\{prefix}#{match[1]}\" should be \"\#{#{match[2].downcase}}\""
|
||||
end
|
||||
end
|
||||
@ -431,13 +431,13 @@ module RuboCop
|
||||
find_every_method_call_by_name(body_node, :depends_on).each do |method|
|
||||
key, value = destructure_hash(parameters(method).first)
|
||||
next if key.nil? || value.nil?
|
||||
next unless match = regex_match_group(value, /^(lua|perl|python|ruby)(\d*)/)
|
||||
next unless (match = regex_match_group(value, /^(lua|perl|python|ruby)(\d*)/))
|
||||
|
||||
problem "#{match[1]} modules should be vendored rather than use deprecated `#{method.source}`"
|
||||
end
|
||||
|
||||
find_every_method_call_by_name(body_node, :system).each do |method|
|
||||
next unless match = regex_match_group(parameters(method).first, /^(env|export)(\s+)?/)
|
||||
next unless (match = regex_match_group(parameters(method).first, /^(env|export)(\s+)?/))
|
||||
|
||||
problem "Use ENV instead of invoking '#{match[1]}' to modify the environment"
|
||||
end
|
||||
@ -449,7 +449,7 @@ module RuboCop
|
||||
|
||||
option_child_nodes.each do |option|
|
||||
find_strings(option).each do |dependency|
|
||||
next unless match = regex_match_group(dependency, /(with(out)?-\w+|c\+\+11)/)
|
||||
next unless (match = regex_match_group(dependency, /(with(out)?-\w+|c\+\+11)/))
|
||||
|
||||
problem "Dependency #{string_content(dep)} should not use option #{match[0]}"
|
||||
end
|
||||
@ -551,7 +551,7 @@ module RuboCop
|
||||
|
||||
path = parameters(method).first
|
||||
next unless path.str_type?
|
||||
next unless match = regex_match_group(path, /^[^*{},]+$/)
|
||||
next unless (match = regex_match_group(path, /^[^*{},]+$/))
|
||||
|
||||
problem "Dir([\"#{string_content(path)}\"]) is unnecessary; just use \"#{match[0]}\""
|
||||
end
|
||||
@ -563,7 +563,7 @@ module RuboCop
|
||||
)
|
||||
find_every_method_call_by_name(body_node, :system).each do |method|
|
||||
param = parameters(method).first
|
||||
next unless match = regex_match_group(param, fileutils_methods)
|
||||
next unless (match = regex_match_group(param, fileutils_methods))
|
||||
|
||||
problem "Use the `#{match}` Ruby method instead of `#{method.source}`"
|
||||
end
|
||||
@ -663,7 +663,7 @@ module RuboCop
|
||||
# Only separate when no shell metacharacters are present
|
||||
next if shell_metacharacters.any? { |meta| string_content(parameters(method).first).include?(meta) }
|
||||
|
||||
next unless match = regex_match_group(parameters(method).first, shell_cmd_with_spaces_regex)
|
||||
next unless (match = regex_match_group(parameters(method).first, shell_cmd_with_spaces_regex))
|
||||
|
||||
good_args = match[0].gsub(" ", "\", \"")
|
||||
offending_node(parameters(method).first)
|
||||
@ -679,7 +679,7 @@ module RuboCop
|
||||
# Only separate when no shell metacharacters are present
|
||||
next if shell_metacharacters.any? { |meta| string_content(parameters(method)[index]).include?(meta) }
|
||||
|
||||
next unless match = regex_match_group(parameters(method)[index], shell_cmd_with_spaces_regex)
|
||||
next unless (match = regex_match_group(parameters(method)[index], shell_cmd_with_spaces_regex))
|
||||
|
||||
good_args = match[0].gsub(" ", "\", \"")
|
||||
offending_node(parameters(method)[index])
|
||||
|
@ -44,7 +44,7 @@ module RuboCop
|
||||
desc_problem "Description shouldn't have trailing spaces." if regex_match_group(desc, /\s+$/)
|
||||
|
||||
# Check if "command-line" is spelled incorrectly in the desc.
|
||||
if match = regex_match_group(desc, /(command ?line)/i)
|
||||
if (match = regex_match_group(desc, /(command ?line)/i))
|
||||
c = match.to_s[0]
|
||||
desc_problem "Description should use \"#{c}ommand-line\" instead of \"#{match}\"."
|
||||
end
|
||||
|
@ -15,7 +15,7 @@ module RuboCop
|
||||
def audit_formula(node, _class_node, _parent_class_node, body_node)
|
||||
full_source_content = source_buffer(node).source
|
||||
|
||||
if match = full_source_content.match(/^require ['"]formula['"]$/)
|
||||
if (match = full_source_content.match(/^require ['"]formula['"]$/))
|
||||
range = source_range(source_buffer(node), match.pre_match.count("\n") + 1, 0, match[0].length)
|
||||
add_offense(range, message: "`#{match}` is now unnecessary") do |corrector|
|
||||
corrector.remove(range_with_surrounding_space(range: range))
|
||||
@ -95,7 +95,7 @@ module RuboCop
|
||||
end
|
||||
|
||||
prefix_path(body_node) do |prefix_node, path|
|
||||
next unless match = path.match(%r{^(bin|include|libexec|lib|sbin|share|Frameworks)(?:/| |$)})
|
||||
next unless (match = path.match(%r{^(bin|include|libexec|lib|sbin|share|Frameworks)(?:/| |$)}))
|
||||
|
||||
offending_node(prefix_node)
|
||||
problem "Use `#{match[1].downcase}` instead of `prefix + \"#{match[1]}\"`"
|
||||
|
@ -10,7 +10,7 @@ module Homebrew
|
||||
# @api private
|
||||
module Search
|
||||
def query_regexp(query)
|
||||
if m = query.match(%r{^/(.*)/$})
|
||||
if (m = query.match(%r{^/(.*)/$}))
|
||||
Regexp.new(m[1])
|
||||
else
|
||||
query
|
||||
|
@ -108,7 +108,7 @@ module Homebrew
|
||||
end
|
||||
|
||||
def check_for_dependents(kegs, casks: [], named_args: [])
|
||||
return false unless result = InstalledDependents.find_some_installed_dependents(kegs, casks: casks)
|
||||
return false unless (result = InstalledDependents.find_some_installed_dependents(kegs, casks: casks))
|
||||
|
||||
if Homebrew::EnvConfig.developer?
|
||||
DeveloperDependentsMessage.new(*result, named_args: named_args).output
|
||||
|
@ -223,7 +223,7 @@ module Kernel
|
||||
tap_message = T.let(nil, T.nilable(String))
|
||||
|
||||
backtrace.each do |line|
|
||||
next unless match = line.match(HOMEBREW_TAP_PATH_REGEX)
|
||||
next unless (match = line.match(HOMEBREW_TAP_PATH_REGEX))
|
||||
|
||||
tap = Tap.fetch(match[:user], match[:repo])
|
||||
tap_message = +"\nPlease report this issue to the #{tap} tap (not Homebrew/brew or Homebrew/core)"
|
||||
|
@ -42,7 +42,7 @@ module PyPI
|
||||
@name = package_string
|
||||
@name, @version = @name.split("==") if @name.include? "=="
|
||||
|
||||
return unless match = @name.match(/^(.*?)\[(.+)\]$/)
|
||||
return unless (match = @name.match(/^(.*?)\[(.+)\]$/))
|
||||
|
||||
@name = match[1]
|
||||
@extras = match[2].split ","
|
||||
|
@ -115,7 +115,7 @@ class Version
|
||||
|
||||
sig { override.params(other: T.untyped).returns(T.nilable(Integer)) }
|
||||
def <=>(other)
|
||||
return unless other = Token.from(other)
|
||||
return unless (other = Token.from(other))
|
||||
|
||||
case other
|
||||
when NullToken
|
||||
@ -158,7 +158,7 @@ class Version
|
||||
|
||||
sig { override.params(other: T.untyped).returns(T.nilable(Integer)) }
|
||||
def <=>(other)
|
||||
return unless other = Token.from(other)
|
||||
return unless (other = Token.from(other))
|
||||
|
||||
case other
|
||||
when StringToken
|
||||
@ -184,7 +184,7 @@ class Version
|
||||
|
||||
sig { override.params(other: T.untyped).returns(T.nilable(Integer)) }
|
||||
def <=>(other)
|
||||
return unless other = Token.from(other)
|
||||
return unless (other = Token.from(other))
|
||||
|
||||
case other
|
||||
when NumericToken
|
||||
@ -216,7 +216,7 @@ class Version
|
||||
|
||||
sig { override.params(other: T.untyped).returns(T.nilable(Integer)) }
|
||||
def <=>(other)
|
||||
return unless other = Token.from(other)
|
||||
return unless (other = Token.from(other))
|
||||
|
||||
case other
|
||||
when AlphaToken
|
||||
@ -235,7 +235,7 @@ class Version
|
||||
|
||||
sig { override.params(other: T.untyped).returns(T.nilable(Integer)) }
|
||||
def <=>(other)
|
||||
return unless other = Token.from(other)
|
||||
return unless (other = Token.from(other))
|
||||
|
||||
case other
|
||||
when BetaToken
|
||||
@ -256,7 +256,7 @@ class Version
|
||||
|
||||
sig { override.params(other: T.untyped).returns(T.nilable(Integer)) }
|
||||
def <=>(other)
|
||||
return unless other = Token.from(other)
|
||||
return unless (other = Token.from(other))
|
||||
|
||||
case other
|
||||
when PreToken
|
||||
@ -277,7 +277,7 @@ class Version
|
||||
|
||||
sig { override.params(other: T.untyped).returns(T.nilable(Integer)) }
|
||||
def <=>(other)
|
||||
return unless other = Token.from(other)
|
||||
return unless (other = Token.from(other))
|
||||
|
||||
case other
|
||||
when RCToken
|
||||
@ -298,7 +298,7 @@ class Version
|
||||
|
||||
sig { override.params(other: T.untyped).returns(T.nilable(Integer)) }
|
||||
def <=>(other)
|
||||
return unless other = Token.from(other)
|
||||
return unless (other = Token.from(other))
|
||||
|
||||
case other
|
||||
when PatchToken
|
||||
@ -317,7 +317,7 @@ class Version
|
||||
|
||||
sig { override.params(other: T.untyped).returns(T.nilable(Integer)) }
|
||||
def <=>(other)
|
||||
return unless other = Token.from(other)
|
||||
return unless (other = Token.from(other))
|
||||
|
||||
case other
|
||||
when PostToken
|
||||
|
Loading…
x
Reference in New Issue
Block a user