fix Lint/DuplicateBranch style
This commit is contained in:
		
							parent
							
								
									dda0dc72a7
								
							
						
					
					
						commit
						50890ebd51
					
				@ -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
 | 
			
		||||
 | 
			
		||||
@ -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
 | 
			
		||||
 | 
			
		||||
@ -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)) }
 | 
			
		||||
 | 
			
		||||
@ -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)
 | 
			
		||||
 | 
			
		||||
@ -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
 | 
			
		||||
 | 
			
		||||
@ -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
 | 
			
		||||
 | 
			
		||||
@ -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)
 | 
			
		||||
 | 
			
		||||
@ -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
 | 
			
		||||
 | 
			
		||||
@ -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
 | 
			
		||||
 | 
			
		||||
@ -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"
 | 
			
		||||
 | 
			
		||||
@ -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
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -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
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user