From 7fb1e8be8764bc8be176db885d4e607a79134ccf Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 13 Nov 2020 06:27:46 +0000 Subject: [PATCH 1/7] build(deps): bump rubocop from 1.2.0 to 1.3.0 in /Library/Homebrew Bumps [rubocop](https://github.com/rubocop-hq/rubocop) from 1.2.0 to 1.3.0. - [Release notes](https://github.com/rubocop-hq/rubocop/releases) - [Changelog](https://github.com/rubocop-hq/rubocop/blob/master/CHANGELOG.md) - [Commits](https://github.com/rubocop-hq/rubocop/compare/v1.2.0...v1.3.0) Signed-off-by: dependabot[bot] --- Library/Homebrew/Gemfile.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Library/Homebrew/Gemfile.lock b/Library/Homebrew/Gemfile.lock index 02126817ec..431972a0e0 100644 --- a/Library/Homebrew/Gemfile.lock +++ b/Library/Homebrew/Gemfile.lock @@ -98,13 +98,13 @@ GEM rspec-support (3.10.0) rspec-wait (0.0.9) rspec (>= 3, < 4) - rubocop (1.2.0) + rubocop (1.3.0) parallel (~> 1.10) parser (>= 2.7.1.5) rainbow (>= 2.2.2, < 4.0) regexp_parser (>= 1.8) rexml - rubocop-ast (>= 1.0.1) + rubocop-ast (>= 1.1.1) ruby-progressbar (~> 1.7) unicode-display_width (>= 1.4.0, < 2.0) rubocop-ast (1.1.1) From dda0dc72a753fcbdb27aec9d1e4dcb53ed73d9bd Mon Sep 17 00:00:00 2001 From: Rylan Polster Date: Fri, 13 Nov 2020 09:49:06 -0500 Subject: [PATCH 2/7] format note comments --- Library/Homebrew/extend/os/mac/hardware/cpu.rb | 2 +- Library/Homebrew/extend/os/mac/keg_relocate.rb | 2 +- Library/Homebrew/test/utils/shell_spec.rb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Library/Homebrew/extend/os/mac/hardware/cpu.rb b/Library/Homebrew/extend/os/mac/hardware/cpu.rb index 746786f98d..7b10da535a 100644 --- a/Library/Homebrew/extend/os/mac/hardware/cpu.rb +++ b/Library/Homebrew/extend/os/mac/hardware/cpu.rb @@ -116,7 +116,7 @@ module Hardware sysctl_bool("hw.optional.sse4_2") end - # Note: this is more reliable than checking uname. + # NOTE: this is more reliable than checking uname. # `sysctl` returns the right answer even when running in Rosetta 2. def physical_cpu_arm64? sysctl_bool("hw.optional.arm64") diff --git a/Library/Homebrew/extend/os/mac/keg_relocate.rb b/Library/Homebrew/extend/os/mac/keg_relocate.rb index 896bc69c85..eae8373747 100644 --- a/Library/Homebrew/extend/os/mac/keg_relocate.rb +++ b/Library/Homebrew/extend/os/mac/keg_relocate.rb @@ -77,7 +77,7 @@ class Keg # remove all RPATHs from the file. if ENV["HOMEBREW_RELOCATE_METAVARS"] && file.dynamically_linked_libraries.none? { |lib| lib.start_with?("@rpath") } - # Note: This could probably be made more efficient by reverse-sorting + # NOTE: This could probably be made more efficient by reverse-sorting # the RPATHs by offset and calling MachOFile#delete_command # with repopulate: false. file.rpaths.each { |r| file.delete_rpath(r) } diff --git a/Library/Homebrew/test/utils/shell_spec.rb b/Library/Homebrew/test/utils/shell_spec.rb index 61c24e745f..3db721c63f 100644 --- a/Library/Homebrew/test/utils/shell_spec.rb +++ b/Library/Homebrew/test/utils/shell_spec.rb @@ -73,7 +73,7 @@ describe Utils::Shell do specify "::csh_quote" do expect(subject.send(:csh_quote, "")).to eq("''") expect(subject.send(:csh_quote, "\\")).to eq("\\\\") - # note this test is different than for sh + # NOTE: this test is different than for sh expect(subject.send(:csh_quote, "\n")).to eq("'\\\n'") expect(subject.send(:csh_quote, "$")).to eq("\\$") expect(subject.send(:csh_quote, "word")).to eq("word") From 50890ebd5168d7f729e5e6534bc5c149f8f5b84f Mon Sep 17 00:00:00 2001 From: Rylan Polster Date: Fri, 13 Nov 2020 10:07:02 -0500 Subject: [PATCH 3/7] fix Lint/DuplicateBranch style --- Library/Homebrew/PATH.rb | 5 +- Library/Homebrew/build.rb | 12 +--- Library/Homebrew/cask/cmd/audit.rb | 6 +- Library/Homebrew/cleaner.rb | 13 ++--- Library/Homebrew/dependency_collector.rb | 2 - Library/Homebrew/download_strategy.rb | 12 ++-- Library/Homebrew/formula.rb | 6 +- Library/Homebrew/formula_installer.rb | 16 ++---- Library/Homebrew/keg.rb | 56 +++++++++---------- .../spec/shared_context/integration_test.rb | 7 +-- Library/Homebrew/upgrade.rb | 8 +-- Library/Homebrew/version.rb | 4 +- 12 files changed, 55 insertions(+), 92 deletions(-) diff --git a/Library/Homebrew/PATH.rb b/Library/Homebrew/PATH.rb index 20b83d0d36..3d5ca1f332 100644 --- a/Library/Homebrew/PATH.rb +++ b/Library/Homebrew/PATH.rb @@ -67,9 +67,8 @@ class PATH sig { params(other: T.untyped).returns(T::Boolean) } def ==(other) - if other.respond_to?(:to_ary) && to_ary == other.to_ary - true - elsif other.respond_to?(:to_str) && to_str == other.to_str + if other.respond_to?(:to_ary) && to_ary == other.to_ary || + other.respond_to?(:to_str) && to_str == other.to_str true else false diff --git a/Library/Homebrew/build.rb b/Library/Homebrew/build.rb index f7c4274874..b24fef7525 100644 --- a/Library/Homebrew/build.rb +++ b/Library/Homebrew/build.rb @@ -53,11 +53,7 @@ class Build def expand_reqs formula.recursive_requirements do |dependent, req| build = effective_build_options_for(dependent) - if req.prune_from_option?(build) - Requirement.prune - elsif req.prune_if_build_and_not_dependent?(dependent, formula) - Requirement.prune - elsif req.test? + if req.prune_from_option?(build) || req.prune_if_build_and_not_dependent?(dependent, formula) || req.test? Requirement.prune end end @@ -66,14 +62,10 @@ class Build def expand_deps formula.recursive_dependencies do |dependent, dep| build = effective_build_options_for(dependent) - if dep.prune_from_option?(build) - Dependency.prune - elsif dep.prune_if_build_and_not_dependent?(dependent, formula) + if dep.prune_from_option?(build) || dep.prune_if_build_and_not_dependent?(dependent, formula) || dep.test? Dependency.prune elsif dep.build? Dependency.keep_but_prune_recursive_deps - elsif dep.test? - Dependency.prune end end end diff --git a/Library/Homebrew/cask/cmd/audit.rb b/Library/Homebrew/cask/cmd/audit.rb index dcfd98741c..4489a80aa3 100644 --- a/Library/Homebrew/cask/cmd/audit.rb +++ b/Library/Homebrew/cask/cmd/audit.rb @@ -60,12 +60,10 @@ module Cask options[:quarantine] = true if options[:quarantine].nil? casks = args.named.flat_map do |name| - if File.exist?(name) + if File.exist?(name) && name.count("/") != 1 name - elsif name.count("/") == 1 - Tap.fetch(name).cask_files else - name + Tap.fetch(name).cask_files end end casks = casks.map { |c| CaskLoader.load(c, config: Config.from_args(args)) } diff --git a/Library/Homebrew/cleaner.rb b/Library/Homebrew/cleaner.rb index 070f5cb213..238a1f0948 100644 --- a/Library/Homebrew/cleaner.rb +++ b/Library/Homebrew/cleaner.rb @@ -93,18 +93,15 @@ class Cleaner next if path.directory? - if path.extname == ".la" - path.unlink - elsif path.symlink? - # Skip it. - elsif path.basename.to_s == "perllocal.pod" - # Both this file & the .packlist one below are completely unnecessary + 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. path.unlink - elsif path.basename.to_s == ".packlist" # Hidden file, not file extension! - path.unlink + elsif path.symlink? + # Skip it. else # Set permissions for executables and non-executables perms = if executable_path?(path) diff --git a/Library/Homebrew/dependency_collector.rb b/Library/Homebrew/dependency_collector.rb index 356437c7a9..c375139955 100644 --- a/Library/Homebrew/dependency_collector.rb +++ b/Library/Homebrew/dependency_collector.rb @@ -115,8 +115,6 @@ class DependencyCollector def parse_string_spec(spec, tags) if spec.match?(HOMEBREW_TAP_FORMULA_REGEX) TapDependency.new(spec, tags) - elsif tags.empty? - Dependency.new(spec, tags) else Dependency.new(spec, tags) end diff --git a/Library/Homebrew/download_strategy.rb b/Library/Homebrew/download_strategy.rb index eb4a48389b..624216d3b2 100644 --- a/Library/Homebrew/download_strategy.rb +++ b/Library/Homebrew/download_strategy.rb @@ -1233,22 +1233,20 @@ class DownloadStrategyDetector when %r{^https?://(.+?\.)?googlecode\.com/svn}, %r{^https?://svn\.}, %r{^svn://}, - %r{^https?://(.+?\.)?sourceforge\.net/svnroot/} + %r{^https?://(.+?\.)?sourceforge\.net/svnroot/}, + %r{^svn\+http://}, + %r{^http://svn\.apache\.org/repos/} SubversionDownloadStrategy when %r{^cvs://} CVSDownloadStrategy when %r{^hg://}, - %r{^https?://(.+?\.)?googlecode\.com/hg} + %r{^https?://(.+?\.)?googlecode\.com/hg}, + %r{^https?://(.+?\.)?sourceforge\.net/hgweb/} MercurialDownloadStrategy when %r{^bzr://} BazaarDownloadStrategy when %r{^fossil://} FossilDownloadStrategy - when %r{^svn\+http://}, - %r{^http://svn\.apache\.org/repos/} - SubversionDownloadStrategy - when %r{^https?://(.+?\.)?sourceforge\.net/hgweb/} - MercurialDownloadStrategy else CurlDownloadStrategy end diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index 10e5347b86..5584605ce7 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -1270,10 +1270,8 @@ class Formula break end - if current_version - [] - elsif (head_version = latest_head_version) && - !head_version_outdated?(head_version, fetch_head: fetch_head) + if current_version || + (latest_head_version && !head_version_outdated?(latest_head_version, fetch_head: fetch_head)) [] else all_kegs += old_installed_formulae.flat_map(&:installed_kegs) diff --git a/Library/Homebrew/formula_installer.rb b/Library/Homebrew/formula_installer.rb index 364aed2746..9be7893ba7 100644 --- a/Library/Homebrew/formula_installer.rb +++ b/Library/Homebrew/formula_installer.rb @@ -534,13 +534,10 @@ class FormulaInstaller keep_build_test ||= req.test? && include_test? && dependent == f keep_build_test ||= req.build? && !install_bottle_for_dependent && !dependent.latest_version_installed? - if req.prune_from_option?(build) - Requirement.prune - elsif req.satisfied?(env: env, cc: cc, build_bottle: @build_bottle, bottle_arch: bottle_arch) - Requirement.prune - elsif (req.build? || req.test?) && !keep_build_test - Requirement.prune - elsif (dep = formula_deps_map[dependent.name]) && dep.build? + 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?) Requirement.prune else unsatisfied_reqs[dependent] << req @@ -569,9 +566,8 @@ 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) - Dependency.prune - elsif (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 diff --git a/Library/Homebrew/keg.rb b/Library/Homebrew/keg.rb index d968c0c5e3..456b769621 100644 --- a/Library/Homebrew/keg.rb +++ b/Library/Homebrew/keg.rb @@ -482,18 +482,18 @@ class Keg link_dir("share", **options) do |relative_path| case relative_path.to_s - when "locale/locale.alias" then :skip_file when INFOFILE_RX then :info - when LOCALEDIR_RX then :mkpath - when %r{^icons/.*/icon-theme\.cache$} then :skip_file - # all icons subfolders should also mkpath - when %r{^icons/} then :mkpath - when /^zsh/ then :mkpath - when /^fish/ then :mkpath - # Lua, Lua51, Lua53 all need the same handling. - when %r{^lua/} then :mkpath - when %r{^guile/} then :mkpath - when *SHARE_PATHS then :mkpath + when "locale/locale.alias", + %r{^icons/.*/icon-theme\.cache$} + :skip_file + when LOCALEDIR_RX, + %r{^icons/}, # all icons subfolders should also mkpath + /^zsh/, + /^fish/, + %r{^lua/}, # Lua, Lua51, Lua53 all need the same handling. + %r{^guile/}, + *SHARE_PATHS + :mkpath else :link end end @@ -501,24 +501,22 @@ class Keg link_dir("lib", **options) do |relative_path| case relative_path.to_s when "charset.alias" then :skip_file - # pkg-config database gets explicitly created - when "pkgconfig" then :mkpath - # cmake database gets explicitly created - when "cmake" then :mkpath - # lib/language folders also get explicitly created - when "dtrace" then :mkpath - when /^gdk-pixbuf/ then :mkpath - when "ghc" then :mkpath - when /^gio/ then :mkpath - when "lua" then :mkpath - when /^mecab/ then :mkpath - when /^node/ then :mkpath - when /^ocaml/ then :mkpath - when /^perl5/ then :mkpath - when "php" then :mkpath - when /^python[23]\.\d/ then :mkpath - when /^R/ then :mkpath - when /^ruby/ then :mkpath + when "pkgconfig", # pkg-config database gets explicitly created + "cmake", # cmake database gets explicitly created + "dtrace", # lib/language folders also get explicitly created + /^gdk-pixbuf/, + "ghc", + /^gio/, + "lua", + /^mecab/, + /^node/, + /^ocaml/, + /^perl5/, + "php", + /^python[23]\.\d/, + /^R/, + /^ruby/, + :mkpath # Everything else is symlinked to the cellar else :link end diff --git a/Library/Homebrew/test/support/helper/spec/shared_context/integration_test.rb b/Library/Homebrew/test/support/helper/spec/shared_context/integration_test.rb index 3d18361e9b..306b33fa9d 100644 --- a/Library/Homebrew/test/support/helper/spec/shared_context/integration_test.rb +++ b/Library/Homebrew/test/support/helper/spec/shared_context/integration_test.rb @@ -151,7 +151,7 @@ RSpec.shared_context "integration test" do # something here RUBY - when "foo" + when "foo", "patchelf" content = <<~RUBY url "https://brew.sh/#{name}-1.0" RUBY @@ -160,11 +160,6 @@ RSpec.shared_context "integration test" do url "https://brew.sh/#{name}-1.0" depends_on "foo" RUBY - when "patchelf" - content = <<~RUBY - url "https://brew.sh/#{name}-1.0" - RUBY - when "package_license" content = <<~RUBY url "https://brew.sh/#patchelf-1.0" diff --git a/Library/Homebrew/upgrade.rb b/Library/Homebrew/upgrade.rb index 1fa4e8313f..15602d126a 100644 --- a/Library/Homebrew/upgrade.rb +++ b/Library/Homebrew/upgrade.rb @@ -103,14 +103,12 @@ module Homebrew # We already attempted to upgrade f as part of the dependency tree of # another formula. In that case, don't generate an error, just move on. nil - rescue CannotInstallFormulaError => e + rescue CannotInstallFormulaError, DownloadError => e ofail e rescue BuildError => e e.dump(verbose: args.verbose?) puts Homebrew.failed = true - rescue DownloadError => e - ofail e ensure # restore previous installation state if build failed begin @@ -241,14 +239,12 @@ module Homebrew # We already attempted to reinstall f as part of the dependency tree of # another formula. In that case, don't generate an error, just move on. nil - rescue CannotInstallFormulaError => e + rescue CannotInstallFormulaError, DownloadError => e ofail e rescue BuildError => e e.dump(verbose: args.verbose?) puts Homebrew.failed = true - rescue DownloadError => e - ofail e end end diff --git a/Library/Homebrew/version.rb b/Library/Homebrew/version.rb index 08c0d76021..547c0c9850 100644 --- a/Library/Homebrew/version.rb +++ b/Library/Homebrew/version.rb @@ -516,7 +516,7 @@ class Version l += 1 r += 1 next - elsif a.numeric? && b.numeric? + elsif a.numeric? == b.numeric? return a <=> b elsif a.numeric? return 1 if a > NULL_TOKEN @@ -526,8 +526,6 @@ class Version return -1 if b > NULL_TOKEN r += 1 - else - return a <=> b end end From 20ee7e888114975487a74167728ec7390cb2236b Mon Sep 17 00:00:00 2001 From: Rylan Polster Date: Fri, 13 Nov 2020 10:57:20 -0500 Subject: [PATCH 4/7] add Lint/DuplicateBranch cop exceptions --- Library/Homebrew/cask/dsl/depends_on.rb | 2 +- Library/Homebrew/dev-cmd/bottle.rb | 2 +- Library/Homebrew/os/mac/xcode.rb | 4 ++++ Library/Homebrew/rubocops/homepage.rb | 2 ++ 4 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Library/Homebrew/cask/dsl/depends_on.rb b/Library/Homebrew/cask/dsl/depends_on.rb index 8e2280459a..8009749896 100644 --- a/Library/Homebrew/cask/dsl/depends_on.rb +++ b/Library/Homebrew/cask/dsl/depends_on.rb @@ -64,7 +64,7 @@ module Cask MacOSRequirement.new([version.to_sym], comparator: comparator) elsif /^\s*(?<|>|[=<>]=)\s*(?\S+)\s*$/ =~ args.first MacOSRequirement.new([version], comparator: comparator) - else + else # rubocop:disable Lint/DuplicateBranch MacOSRequirement.new([args.first], comparator: "==") end rescue MacOSVersionError => e diff --git a/Library/Homebrew/dev-cmd/bottle.rb b/Library/Homebrew/dev-cmd/bottle.rb index b940b0d934..8ea244534f 100644 --- a/Library/Homebrew/dev-cmd/bottle.rb +++ b/Library/Homebrew/dev-cmd/bottle.rb @@ -450,7 +450,7 @@ module Homebrew "any" elsif cellars.include?("any_skip_relocation") "any_skip_relocation" - else + else # rubocop:disable Lint/DuplicateBranch second end else diff --git a/Library/Homebrew/os/mac/xcode.rb b/Library/Homebrew/os/mac/xcode.rb index a2c833655b..d4aa31ee6b 100644 --- a/Library/Homebrew/os/mac/xcode.rb +++ b/Library/Homebrew/os/mac/xcode.rb @@ -189,6 +189,7 @@ 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 @@ -205,6 +206,7 @@ module OS when 0 then "dunno" else latest_stable end + # rubocop:enable Lint/DuplicateBranch end def default_prefix? @@ -274,6 +276,7 @@ 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 @@ -287,6 +290,7 @@ 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 diff --git a/Library/Homebrew/rubocops/homepage.rb b/Library/Homebrew/rubocops/homepage.rb index c8f802a2c1..d5b37d91b3 100644 --- a/Library/Homebrew/rubocops/homepage.rb +++ b/Library/Homebrew/rubocops/homepage.rb @@ -22,6 +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 @@ -88,6 +89,7 @@ module RuboCop %r{^http://(?:[^/]*\.)?archive\.org} problem "Please use https:// for #{homepage}" end + # rubocop:enable Lint/DuplicateBranch end def autocorrect(node) From f2693a0a0056a38d55de26789def44c265ccadb8 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Fri, 13 Nov 2020 16:17:06 +0100 Subject: [PATCH 5/7] brew vendor-gems: commit updates. --- Library/Homebrew/vendor/bundle/bundler/setup.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Library/Homebrew/vendor/bundle/bundler/setup.rb b/Library/Homebrew/vendor/bundle/bundler/setup.rb index d6c83a98a2..dfd4450aaf 100644 --- a/Library/Homebrew/vendor/bundle/bundler/setup.rb +++ b/Library/Homebrew/vendor/bundle/bundler/setup.rb @@ -72,7 +72,7 @@ $:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rspec-wait-0.0.9/lib" $:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-ast-1.1.1/lib" $:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/ruby-progressbar-1.10.1/lib" $:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/unicode-display_width-1.7.0/lib" -$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-1.2.0/lib" +$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-1.3.0/lib" $:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-performance-1.8.1/lib" $:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-rspec-2.0.0/lib" $:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-sorbet-0.5.1/lib" From 1b732ec7b2952b47c0c80e6cde3f3b61f2cbb669 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Fri, 13 Nov 2020 17:21:51 +0100 Subject: [PATCH 6/7] Fix RuboCop offenses. --- Library/Homebrew/PATH.rb | 7 ++-- Library/Homebrew/build.rb | 4 ++- Library/Homebrew/cask/cmd/audit.rb | 9 +++-- Library/Homebrew/cleaner.rb | 13 +++---- Library/Homebrew/dev-cmd/bottle.rb | 22 ++++-------- Library/Homebrew/download_strategy.rb | 4 +-- Library/Homebrew/formula.rb | 2 +- Library/Homebrew/formula_installer.rb | 5 ++- Library/Homebrew/keg.rb | 13 ++++--- Library/Homebrew/os/mac/xcode.rb | 31 +++++++---------- Library/Homebrew/rubocops/homepage.rb | 49 ++++++++++++--------------- Library/Homebrew/version.rb | 8 ++--- 12 files changed, 73 insertions(+), 94 deletions(-) diff --git a/Library/Homebrew/PATH.rb b/Library/Homebrew/PATH.rb index 3d5ca1f332..a69709e9c9 100644 --- a/Library/Homebrew/PATH.rb +++ b/Library/Homebrew/PATH.rb @@ -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) } diff --git a/Library/Homebrew/build.rb b/Library/Homebrew/build.rb index b24fef7525..94b928211c 100644 --- a/Library/Homebrew/build.rb +++ b/Library/Homebrew/build.rb @@ -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 diff --git a/Library/Homebrew/cask/cmd/audit.rb b/Library/Homebrew/cask/cmd/audit.rb index 4489a80aa3..3655f0313d 100644 --- a/Library/Homebrew/cask/cmd/audit.rb +++ b/Library/Homebrew/cask/cmd/audit.rb @@ -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? diff --git a/Library/Homebrew/cleaner.rb b/Library/Homebrew/cleaner.rb index 238a1f0948..6acc77f1a9 100644 --- a/Library/Homebrew/cleaner.rb +++ b/Library/Homebrew/cleaner.rb @@ -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. diff --git a/Library/Homebrew/dev-cmd/bottle.rb b/Library/Homebrew/dev-cmd/bottle.rb index 8ea244534f..946d0a912a 100644 --- a/Library/Homebrew/dev-cmd/bottle.rb +++ b/Library/Homebrew/dev-cmd/bottle.rb @@ -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 diff --git a/Library/Homebrew/download_strategy.rb b/Library/Homebrew/download_strategy.rb index 624216d3b2..81dcf445fc 100644 --- a/Library/Homebrew/download_strategy.rb +++ b/Library/Homebrew/download_strategy.rb @@ -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 diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index 5584605ce7..26b0846459 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -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) diff --git a/Library/Homebrew/formula_installer.rb b/Library/Homebrew/formula_installer.rb index 9be7893ba7..ed4bdd46ce 100644 --- a/Library/Homebrew/formula_installer.rb +++ b/Library/Homebrew/formula_installer.rb @@ -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 diff --git a/Library/Homebrew/keg.rb b/Library/Homebrew/keg.rb index 456b769621..80ba0608bd 100644 --- a/Library/Homebrew/keg.rb +++ b/Library/Homebrew/keg.rb @@ -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 diff --git a/Library/Homebrew/os/mac/xcode.rb b/Library/Homebrew/os/mac/xcode.rb index d4aa31ee6b..769f373d37 100644 --- a/Library/Homebrew/os/mac/xcode.rb +++ b/Library/Homebrew/os/mac/xcode.rb @@ -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 diff --git a/Library/Homebrew/rubocops/homepage.rb b/Library/Homebrew/rubocops/homepage.rb index d5b37d91b3..c41c02d041 100644 --- a/Library/Homebrew/rubocops/homepage.rb +++ b/Library/Homebrew/rubocops/homepage.rb @@ -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) diff --git a/Library/Homebrew/version.rb b/Library/Homebrew/version.rb index 547c0c9850..8c1735e9a1 100644 --- a/Library/Homebrew/version.rb +++ b/Library/Homebrew/version.rb @@ -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 From bfe9598fa95f3e0fc9bf6dc8c14084a6cc5a9e1b Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Mon, 16 Nov 2020 03:13:39 +0100 Subject: [PATCH 7/7] Disable `Lint/DuplicateBranch` cop for formulae and casks. --- Library/.rubocop.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Library/.rubocop.yml b/Library/.rubocop.yml index f1ca45af7f..c9134c5611 100644 --- a/Library/.rubocop.yml +++ b/Library/.rubocop.yml @@ -197,6 +197,10 @@ Layout/RescueEnsureAlignment: Lint/AmbiguousBlockAssociation: Enabled: false +Lint/DuplicateBranch: + Exclude: + - 'Taps/*/*/{Formula,Casks,}/*.rb' + # needed for lazy_object magic Naming/MemoizedInstanceVariableName: Exclude: