mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
Fix RuboCop offenses.
This commit is contained in:
parent
f2693a0a00
commit
1b732ec7b2
@ -67,12 +67,9 @@ class PATH
|
||||
|
||||
sig { params(other: T.untyped).returns(T::Boolean) }
|
||||
def ==(other)
|
||||
if other.respond_to?(:to_ary) && to_ary == other.to_ary ||
|
||||
other.respond_to?(:to_str) && to_str == other.to_str
|
||||
true
|
||||
else
|
||||
(other.respond_to?(:to_ary) && to_ary == other.to_ary) ||
|
||||
(other.respond_to?(:to_str) && to_str == other.to_str) ||
|
||||
false
|
||||
end
|
||||
end
|
||||
|
||||
sig { returns(T::Boolean) }
|
||||
|
@ -62,7 +62,9 @@ class Build
|
||||
def expand_deps
|
||||
formula.recursive_dependencies do |dependent, dep|
|
||||
build = effective_build_options_for(dependent)
|
||||
if dep.prune_from_option?(build) || dep.prune_if_build_and_not_dependent?(dependent, formula) || dep.test?
|
||||
if dep.prune_from_option?(build) ||
|
||||
dep.prune_if_build_and_not_dependent?(dependent, formula) ||
|
||||
(dep.test? && !dep.build?)
|
||||
Dependency.prune
|
||||
elsif dep.build?
|
||||
Dependency.keep_but_prune_recursive_deps
|
||||
|
@ -60,11 +60,10 @@ module Cask
|
||||
options[:quarantine] = true if options[:quarantine].nil?
|
||||
|
||||
casks = args.named.flat_map do |name|
|
||||
if File.exist?(name) && name.count("/") != 1
|
||||
name
|
||||
else
|
||||
Tap.fetch(name).cask_files
|
||||
end
|
||||
next name if File.exist?(name)
|
||||
next Tap.fetch(name).cask_files if name.count("/") == 1
|
||||
|
||||
name
|
||||
end
|
||||
casks = casks.map { |c| CaskLoader.load(c, config: Config.from_args(args)) }
|
||||
casks = Cask.to_a if casks.empty?
|
||||
|
@ -76,6 +76,12 @@ class Cleaner
|
||||
path.text_executable? || path.executable?
|
||||
end
|
||||
|
||||
# Both these files are completely unnecessary to package and cause
|
||||
# pointless conflicts with other formulae. They are removed by Debian,
|
||||
# Arch & MacPorts amongst other packagers as well. The files are
|
||||
# created as part of installing any Perl module.
|
||||
PERL_BASENAMES = Set.new(%w[perllocal.pod .packlist]).freeze
|
||||
|
||||
# Clean a top-level (bin, sbin, lib) directory, recursively, by fixing file
|
||||
# permissions and removing .la files, unless the files (or parent
|
||||
# directories) are protected by skip_clean.
|
||||
@ -93,12 +99,7 @@ class Cleaner
|
||||
|
||||
next if path.directory?
|
||||
|
||||
files_to_skip = %w[perllocal.pod .packlist]
|
||||
if path.extname == ".la" || (!path.symlink? && files_to_skip.include?(path.basename.to_s))
|
||||
# Both the `perllocal.pod` & `.packlist` files are completely unnecessary
|
||||
# to package & causes pointless conflict with other formulae. They are
|
||||
# removed by Debian, Arch & MacPorts amongst other packagers as well.
|
||||
# The files are created as part of installing any Perl module.
|
||||
if path.extname == ".la" || PERL_BASENAMES.include?(path.basename.to_s)
|
||||
path.unlink
|
||||
elsif path.symlink?
|
||||
# Skip it.
|
||||
|
@ -440,22 +440,14 @@ module Homebrew
|
||||
if key == "cellar"
|
||||
# Prioritize HOMEBREW_CELLAR over :any over :any_skip_relocation
|
||||
cellars = [first, second]
|
||||
if cellars.include?(HOMEBREW_CELLAR)
|
||||
HOMEBREW_CELLAR
|
||||
elsif first.start_with?("/")
|
||||
first
|
||||
elsif second.start_with?("/")
|
||||
second
|
||||
elsif cellars.include?("any")
|
||||
"any"
|
||||
elsif cellars.include?("any_skip_relocation")
|
||||
"any_skip_relocation"
|
||||
else # rubocop:disable Lint/DuplicateBranch
|
||||
second
|
||||
end
|
||||
else
|
||||
second
|
||||
next HOMEBREW_CELLAR if cellars.include?(HOMEBREW_CELLAR)
|
||||
next first if first.start_with?("/")
|
||||
next second if second.start_with?("/")
|
||||
next "any" if cellars.include?("any")
|
||||
next "any_skip_relocation" if cellars.include?("any_skip_relocation")
|
||||
end
|
||||
|
||||
second
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -1233,9 +1233,9 @@ class DownloadStrategyDetector
|
||||
when %r{^https?://(.+?\.)?googlecode\.com/svn},
|
||||
%r{^https?://svn\.},
|
||||
%r{^svn://},
|
||||
%r{^https?://(.+?\.)?sourceforge\.net/svnroot/},
|
||||
%r{^svn\+http://},
|
||||
%r{^http://svn\.apache\.org/repos/}
|
||||
%r{^http://svn\.apache\.org/repos/},
|
||||
%r{^https?://(.+?\.)?sourceforge\.net/svnroot/}
|
||||
SubversionDownloadStrategy
|
||||
when %r{^cvs://}
|
||||
CVSDownloadStrategy
|
||||
|
@ -1271,7 +1271,7 @@ class Formula
|
||||
end
|
||||
|
||||
if current_version ||
|
||||
(latest_head_version && !head_version_outdated?(latest_head_version, fetch_head: fetch_head))
|
||||
((head_version = latest_head_version) && !head_version_outdated?(head_version, fetch_head: fetch_head))
|
||||
[]
|
||||
else
|
||||
all_kegs += old_installed_formulae.flat_map(&:installed_kegs)
|
||||
|
@ -537,7 +537,7 @@ class FormulaInstaller
|
||||
if req.prune_from_option?(build) ||
|
||||
req.satisfied?(env: env, cc: cc, build_bottle: @build_bottle, bottle_arch: bottle_arch) ||
|
||||
((req.build? || req.test?) && !keep_build_test) ||
|
||||
(formula_deps_map.key?(dependent.name) && formula_deps_map[dependent.name].build?)
|
||||
formula_deps_map[dependent.name]&.build?
|
||||
Requirement.prune
|
||||
else
|
||||
unsatisfied_reqs[dependent] << req
|
||||
@ -566,8 +566,7 @@ class FormulaInstaller
|
||||
keep_build_test ||= dep.test? && include_test? && include_test_formulae.include?(dependent.full_name)
|
||||
keep_build_test ||= dep.build? && !install_bottle_for?(dependent, build) && !dependent.latest_version_installed?
|
||||
|
||||
if dep.prune_from_option?(build) ||
|
||||
((dep.build? || dep.test?) && !keep_build_test)
|
||||
if dep.prune_from_option?(build) || ((dep.build? || dep.test?) && !keep_build_test)
|
||||
Dependency.prune
|
||||
elsif dep.satisfied?(inherited_options[dep.name])
|
||||
Dependency.skip
|
||||
|
@ -494,13 +494,15 @@ class Keg
|
||||
%r{^guile/},
|
||||
*SHARE_PATHS
|
||||
:mkpath
|
||||
else :link
|
||||
else
|
||||
:link
|
||||
end
|
||||
end
|
||||
|
||||
link_dir("lib", **options) do |relative_path|
|
||||
case relative_path.to_s
|
||||
when "charset.alias" then :skip_file
|
||||
when "charset.alias"
|
||||
:skip_file
|
||||
when "pkgconfig", # pkg-config database gets explicitly created
|
||||
"cmake", # cmake database gets explicitly created
|
||||
"dtrace", # lib/language folders also get explicitly created
|
||||
@ -515,10 +517,11 @@ class Keg
|
||||
"php",
|
||||
/^python[23]\.\d/,
|
||||
/^R/,
|
||||
/^ruby/,
|
||||
/^ruby/
|
||||
:mkpath
|
||||
# Everything else is symlinked to the cellar
|
||||
else :link
|
||||
else
|
||||
# Everything else is symlinked to the cellar
|
||||
:link
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -189,24 +189,20 @@ module OS
|
||||
# installed CLT version. This is useful as they are packaged
|
||||
# simultaneously so workarounds need to apply to both based on their
|
||||
# comparable version.
|
||||
# rubocop:disable Lint/DuplicateBranch
|
||||
latest_stable = "12.0"
|
||||
case (DevelopmentTools.clang_version.to_f * 10).to_i
|
||||
when 120 then latest_stable
|
||||
when 110 then "11.5"
|
||||
when 100 then "10.3"
|
||||
when 91 then "9.4"
|
||||
when 90 then "9.2"
|
||||
when 81 then "8.3"
|
||||
when 80 then "8.0"
|
||||
when 73 then "7.3"
|
||||
when 70 then "7.0"
|
||||
when 61 then "6.1"
|
||||
when 60 then "6.0"
|
||||
when 0 then "dunno"
|
||||
else latest_stable
|
||||
when 60 then "6.0"
|
||||
when 61 then "6.1"
|
||||
when 70 then "7.0"
|
||||
when 73 then "7.3"
|
||||
when 80 then "8.0"
|
||||
when 81 then "8.3"
|
||||
when 90 then "9.2"
|
||||
when 91 then "9.4"
|
||||
when 100 then "10.3"
|
||||
when 110 then "11.5"
|
||||
else "12.0"
|
||||
end
|
||||
# rubocop:enable Lint/DuplicateBranch
|
||||
end
|
||||
|
||||
def default_prefix?
|
||||
@ -276,12 +272,10 @@ module OS
|
||||
|
||||
# Bump these when the new version is distributed through Software Update
|
||||
# and our CI systems have been updated.
|
||||
# rubocop:disable Lint/DuplicateBranch
|
||||
sig { returns(String) }
|
||||
def latest_clang_version
|
||||
case MacOS.version
|
||||
when "11.0" then "1200.0.32.27"
|
||||
when "10.15" then "1200.0.32.27"
|
||||
when "11.0", "10.15" then "1200.0.32.27"
|
||||
when "10.14" then "1100.0.33.17"
|
||||
when "10.13" then "1000.10.44.2"
|
||||
when "10.12" then "900.0.39.2"
|
||||
@ -290,7 +284,6 @@ module OS
|
||||
else "600.0.57"
|
||||
end
|
||||
end
|
||||
# rubocop:enable Lint/DuplicateBranch
|
||||
|
||||
# Bump these if things are badly broken (e.g. no SDK for this macOS)
|
||||
# without this. Generally this will be the first stable CLT release on
|
||||
|
@ -22,18 +22,7 @@ module RuboCop
|
||||
problem "The homepage should start with http or https (URL is #{homepage})."
|
||||
end
|
||||
|
||||
# rubocop:disable Lint/DuplicateBranch
|
||||
case homepage
|
||||
# Check for http:// GitHub homepage URLs, https:// is preferred.
|
||||
# Note: only check homepages that are repo pages, not *.github.com hosts
|
||||
when %r{^http://github.com/}
|
||||
problem "Please use https:// for #{homepage}"
|
||||
|
||||
# Savannah has full SSL/TLS support but no auto-redirect.
|
||||
# Doesn't apply to the download URLs, only the homepage.
|
||||
when %r{^http://savannah.nongnu.org/}
|
||||
problem "Please use https:// for #{homepage}"
|
||||
|
||||
# Freedesktop is complicated to handle - It has SSL/TLS, but only on certain subdomains.
|
||||
# To enable https Freedesktop change the URL from http://project.freedesktop.org/wiki to
|
||||
# https://wiki.freedesktop.org/project_name.
|
||||
@ -49,14 +38,6 @@ module RuboCop
|
||||
when %r{^https?://code\.google\.com/p/[^/]+[^/]$}
|
||||
problem "#{homepage} should end with a slash"
|
||||
|
||||
# People will run into mixed content sometimes, but we should enforce and then add
|
||||
# exemptions as they are discovered. Treat mixed content on homepages as a bug.
|
||||
# Justify each exemptions with a code comment so we can keep track here.
|
||||
|
||||
when %r{^http://[^/]*\.github\.io/},
|
||||
%r{^http://[^/]*\.sourceforge\.io/}
|
||||
problem "Please use https:// for #{homepage}"
|
||||
|
||||
when %r{^http://([^/]*)\.(sf|sourceforge)\.net(/|$)}
|
||||
problem "#{homepage} should be `https://#{Regexp.last_match(1)}.sourceforge.io/`"
|
||||
|
||||
@ -68,15 +49,28 @@ module RuboCop
|
||||
offending_node(parameters(homepage_node).first)
|
||||
problem "GitHub homepages (`#{homepage}`) should not end with .git"
|
||||
|
||||
# There's an auto-redirect here, but this mistake is incredibly common too.
|
||||
# Only applies to the homepage and subdomains for now, not the FTP URLs.
|
||||
when %r{^http://((?:build|cloud|developer|download|extensions|git|
|
||||
glade|help|library|live|nagios|news|people|
|
||||
projects|rt|static|wiki|www)\.)?gnome\.org}x
|
||||
problem "Please use https:// for #{homepage}"
|
||||
|
||||
# People will run into mixed content sometimes, but we should enforce and then add
|
||||
# exemptions as they are discovered. Treat mixed content on homepages as a bug.
|
||||
# Justify each exemptions with a code comment so we can keep track here.
|
||||
#
|
||||
# Compact the above into this list as we're able to remove detailed notations, etc over time.
|
||||
when %r{^http://[^/]*\.apache\.org},
|
||||
when
|
||||
# Check for http:// GitHub homepage URLs, https:// is preferred.
|
||||
# Note: only check homepages that are repo pages, not *.github.com hosts
|
||||
%r{^http://github.com/},
|
||||
%r{^http://[^/]*\.github\.io/},
|
||||
|
||||
# Savannah has full SSL/TLS support but no auto-redirect.
|
||||
# Doesn't apply to the download URLs, only the homepage.
|
||||
%r{^http://savannah.nongnu.org/},
|
||||
|
||||
%r{^http://[^/]*\.sourceforge\.io/},
|
||||
# There's an auto-redirect here, but this mistake is incredibly common too.
|
||||
# Only applies to the homepage and subdomains for now, not the FTP URLs.
|
||||
%r{^http://((?:build|cloud|developer|download|extensions|git|
|
||||
glade|help|library|live|nagios|news|people|
|
||||
projects|rt|static|wiki|www)\.)?gnome\.org}x,
|
||||
%r{^http://[^/]*\.apache\.org},
|
||||
%r{^http://packages\.debian\.org},
|
||||
%r{^http://wiki\.freedesktop\.org/},
|
||||
%r{^http://((?:www)\.)?gnupg\.org/},
|
||||
@ -89,7 +83,6 @@ module RuboCop
|
||||
%r{^http://(?:[^/]*\.)?archive\.org}
|
||||
problem "Please use https:// for #{homepage}"
|
||||
end
|
||||
# rubocop:enable Lint/DuplicateBranch
|
||||
end
|
||||
|
||||
def autocorrect(node)
|
||||
|
@ -516,16 +516,16 @@ class Version
|
||||
l += 1
|
||||
r += 1
|
||||
next
|
||||
elsif a.numeric? == b.numeric?
|
||||
return a <=> b
|
||||
elsif a.numeric?
|
||||
elsif a.numeric? && !b.numeric?
|
||||
return 1 if a > NULL_TOKEN
|
||||
|
||||
l += 1
|
||||
elsif b.numeric?
|
||||
elsif !a.numeric? && b.numeric?
|
||||
return -1 if b > NULL_TOKEN
|
||||
|
||||
r += 1
|
||||
else
|
||||
return a <=> b
|
||||
end
|
||||
end
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user