Autocorrect Rubocop Style/PerlBackrefs.
This commit is contained in:
		
							parent
							
								
									564b03aa01
								
							
						
					
					
						commit
						7a0aff1080
					
				@ -79,7 +79,7 @@ module Homebrew
 | 
			
		||||
 | 
			
		||||
  def github_remote_path(remote, path)
 | 
			
		||||
    if remote =~ %r{^(?:https?://|git(?:@|://))github\.com[:/](.+)/(.+?)(?:\.git)?$}
 | 
			
		||||
      "https://github.com/#{$1}/#{$2}/blob/master/#{path}"
 | 
			
		||||
      "https://github.com/#{Regexp.last_match(1)}/#{Regexp.last_match(2)}/blob/master/#{path}"
 | 
			
		||||
    else
 | 
			
		||||
      "#{remote}/#{path}"
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
@ -80,7 +80,7 @@ module Homebrew
 | 
			
		||||
        if name !~ HOMEBREW_TAP_FORMULA_REGEX && name !~ HOMEBREW_CASK_TAP_CASK_REGEX
 | 
			
		||||
          next
 | 
			
		||||
        end
 | 
			
		||||
        tap = Tap.fetch($1, $2)
 | 
			
		||||
        tap = Tap.fetch(Regexp.last_match(1), Regexp.last_match(2))
 | 
			
		||||
        tap.install unless tap.installed?
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
@ -93,7 +93,7 @@ module Homebrew
 | 
			
		||||
 | 
			
		||||
  def query_regexp(query)
 | 
			
		||||
    case query
 | 
			
		||||
    when %r{^/(.*)/$} then Regexp.new($1)
 | 
			
		||||
    when %r{^/(.*)/$} then Regexp.new(Regexp.last_match(1))
 | 
			
		||||
    else /.*#{Regexp.escape(query)}.*/i
 | 
			
		||||
    end
 | 
			
		||||
  rescue RegexpError
 | 
			
		||||
 | 
			
		||||
@ -578,7 +578,7 @@ class FormulaAuditor
 | 
			
		||||
 | 
			
		||||
      next unless o.name =~ /^with(out)?-(?:checks?|tests)$/
 | 
			
		||||
      unless formula.deps.any? { |d| d.name == "check" && (d.optional? || d.recommended?) }
 | 
			
		||||
        problem "Use '--with#{$1}-test' instead of '--#{o.name}'. Migrate '--#{o.name}' with `deprecated_option`."
 | 
			
		||||
        problem "Use '--with#{Regexp.last_match(1)}-test' instead of '--#{o.name}'. Migrate '--#{o.name}' with `deprecated_option`."
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
@ -722,7 +722,7 @@ class FormulaAuditor
 | 
			
		||||
    stable = formula.stable
 | 
			
		||||
    case stable && stable.url
 | 
			
		||||
    when /[\d\._-](alpha|beta|rc\d)/
 | 
			
		||||
      matched = $1
 | 
			
		||||
      matched = Regexp.last_match(1)
 | 
			
		||||
      version_prefix = stable.version.to_s.sub(/\d+$/, "")
 | 
			
		||||
      return if unstable_whitelist.include?([formula.name, version_prefix])
 | 
			
		||||
      problem "Stable version URLs should not contain #{matched}"
 | 
			
		||||
@ -837,7 +837,7 @@ class FormulaAuditor
 | 
			
		||||
    when %r{https?://patch-diff\.githubusercontent\.com/raw/(.+)/(.+)/pull/(.+)\.(?:diff|patch)}
 | 
			
		||||
      problem <<-EOS.undent
 | 
			
		||||
        use GitHub pull request URLs:
 | 
			
		||||
          https://github.com/#{$1}/#{$2}/pull/#{$3}.patch
 | 
			
		||||
          https://github.com/#{Regexp.last_match(1)}/#{Regexp.last_match(2)}/pull/#{Regexp.last_match(3)}.patch
 | 
			
		||||
        Rather than patch-diff:
 | 
			
		||||
          #{patch.url}
 | 
			
		||||
      EOS
 | 
			
		||||
@ -875,7 +875,7 @@ class FormulaAuditor
 | 
			
		||||
 | 
			
		||||
  def line_problems(line, _lineno)
 | 
			
		||||
    if line =~ /<(Formula|AmazonWebServicesFormula|ScriptFileFormula|GithubGistFormula)/
 | 
			
		||||
      problem "Use a space in class inheritance: class Foo < #{$1}"
 | 
			
		||||
      problem "Use a space in class inheritance: class Foo < #{Regexp.last_match(1)}"
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    # Commented-out cmake support from default template
 | 
			
		||||
@ -899,52 +899,52 @@ class FormulaAuditor
 | 
			
		||||
    # FileUtils is included in Formula
 | 
			
		||||
    # encfs modifies a file with this name, so check for some leading characters
 | 
			
		||||
    if line =~ %r{[^'"/]FileUtils\.(\w+)}
 | 
			
		||||
      problem "Don't need 'FileUtils.' before #{$1}."
 | 
			
		||||
      problem "Don't need 'FileUtils.' before #{Regexp.last_match(1)}."
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    # Check for long inreplace block vars
 | 
			
		||||
    if line =~ /inreplace .* do \|(.{2,})\|/
 | 
			
		||||
      problem "\"inreplace <filenames> do |s|\" is preferred over \"|#{$1}|\"."
 | 
			
		||||
      problem "\"inreplace <filenames> do |s|\" is preferred over \"|#{Regexp.last_match(1)}|\"."
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    # Check for string interpolation of single values.
 | 
			
		||||
    if line =~ /(system|inreplace|gsub!|change_make_var!).*[ ,]"#\{([\w.]+)\}"/
 | 
			
		||||
      problem "Don't need to interpolate \"#{$2}\" with #{$1}"
 | 
			
		||||
      problem "Don't need to interpolate \"#{Regexp.last_match(2)}\" with #{Regexp.last_match(1)}"
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    # Check for string concatenation; prefer interpolation
 | 
			
		||||
    if line =~ /(#\{\w+\s*\+\s*['"][^}]+\})/
 | 
			
		||||
      problem "Try not to concatenate paths in string interpolation:\n   #{$1}"
 | 
			
		||||
      problem "Try not to concatenate paths in string interpolation:\n   #{Regexp.last_match(1)}"
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    # Prefer formula path shortcuts in Pathname+
 | 
			
		||||
    if line =~ %r{\(\s*(prefix\s*\+\s*(['"])(bin|include|libexec|lib|sbin|share|Frameworks)[/'"])}
 | 
			
		||||
      problem "\"(#{$1}...#{$2})\" should be \"(#{$3.downcase}+...)\""
 | 
			
		||||
      problem "\"(#{Regexp.last_match(1)}...#{Regexp.last_match(2)})\" should be \"(#{Regexp.last_match(3).downcase}+...)\""
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    if line =~ /((man)\s*\+\s*(['"])(man[1-8])(['"]))/
 | 
			
		||||
      problem "\"#{$1}\" should be \"#{$4}\""
 | 
			
		||||
      problem "\"#{Regexp.last_match(1)}\" should be \"#{Regexp.last_match(4)}\""
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    # Prefer formula path shortcuts in strings
 | 
			
		||||
    if line =~ %r[(\#\{prefix\}/(bin|include|libexec|lib|sbin|share|Frameworks))]
 | 
			
		||||
      problem "\"#{$1}\" should be \"\#{#{$2.downcase}}\""
 | 
			
		||||
      problem "\"#{Regexp.last_match(1)}\" should be \"\#{#{Regexp.last_match(2).downcase}}\""
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    if line =~ %r[((\#\{prefix\}/share/man/|\#\{man\}/)(man[1-8]))]
 | 
			
		||||
      problem "\"#{$1}\" should be \"\#{#{$3}}\""
 | 
			
		||||
      problem "\"#{Regexp.last_match(1)}\" should be \"\#{#{Regexp.last_match(3)}}\""
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    if line =~ %r[((\#\{share\}/(man)))[/'"]]
 | 
			
		||||
      problem "\"#{$1}\" should be \"\#{#{$3}}\""
 | 
			
		||||
      problem "\"#{Regexp.last_match(1)}\" should be \"\#{#{Regexp.last_match(3)}}\""
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    if line =~ %r[(\#\{prefix\}/share/(info|man))]
 | 
			
		||||
      problem "\"#{$1}\" should be \"\#{#{$2}}\""
 | 
			
		||||
      problem "\"#{Regexp.last_match(1)}\" should be \"\#{#{Regexp.last_match(2)}}\""
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    if line =~ /depends_on :(automake|autoconf|libtool)/
 | 
			
		||||
      problem ":#{$1} is deprecated. Usage should be \"#{$1}\""
 | 
			
		||||
      problem ":#{Regexp.last_match(1)} is deprecated. Usage should be \"#{Regexp.last_match(1)}\""
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    if line =~ /depends_on :apr/
 | 
			
		||||
@ -954,23 +954,23 @@ class FormulaAuditor
 | 
			
		||||
    problem ":tex is deprecated" if line =~ /depends_on :tex/
 | 
			
		||||
 | 
			
		||||
    if line =~ /depends_on\s+['"](.+)['"]\s+=>\s+:(lua|perl|python|ruby)(\d*)/
 | 
			
		||||
      problem "#{$2} modules should be vendored rather than use deprecated `depends_on \"#{$1}\" => :#{$2}#{$3}`"
 | 
			
		||||
      problem "#{Regexp.last_match(2)} modules should be vendored rather than use deprecated `depends_on \"#{Regexp.last_match(1)}\" => :#{Regexp.last_match(2)}#{Regexp.last_match(3)}`"
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    if line =~ /depends_on\s+['"](.+)['"]\s+=>\s+(.*)/
 | 
			
		||||
      dep = $1
 | 
			
		||||
      $2.split(" ").map do |o|
 | 
			
		||||
      dep = Regexp.last_match(1)
 | 
			
		||||
      Regexp.last_match(2).split(" ").map do |o|
 | 
			
		||||
        break if ["if", "unless"].include?(o)
 | 
			
		||||
        next unless o =~ /^\[?['"](.*)['"]/
 | 
			
		||||
        problem "Dependency #{dep} should not use option #{$1}"
 | 
			
		||||
        problem "Dependency #{dep} should not use option #{Regexp.last_match(1)}"
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    # Commented-out depends_on
 | 
			
		||||
    problem "Commented-out dep #{$1}" if line =~ /#\s*depends_on\s+(.+)\s*$/
 | 
			
		||||
    problem "Commented-out dep #{Regexp.last_match(1)}" if line =~ /#\s*depends_on\s+(.+)\s*$/
 | 
			
		||||
 | 
			
		||||
    if line =~ /if\s+ARGV\.include\?\s+'--(HEAD|devel)'/
 | 
			
		||||
      problem "Use \"if build.#{$1.downcase}?\" instead"
 | 
			
		||||
      problem "Use \"if build.#{Regexp.last_match(1).downcase}?\" instead"
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    problem "Use separate make calls" if line.include?("make && make")
 | 
			
		||||
@ -983,15 +983,15 @@ class FormulaAuditor
 | 
			
		||||
 | 
			
		||||
    # Avoid hard-coding compilers
 | 
			
		||||
    if line =~ %r{(system|ENV\[.+\]\s?=)\s?['"](/usr/bin/)?(gcc|llvm-gcc|clang)['" ]}
 | 
			
		||||
      problem "Use \"\#{ENV.cc}\" instead of hard-coding \"#{$3}\""
 | 
			
		||||
      problem "Use \"\#{ENV.cc}\" instead of hard-coding \"#{Regexp.last_match(3)}\""
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    if line =~ %r{(system|ENV\[.+\]\s?=)\s?['"](/usr/bin/)?((g|llvm-g|clang)\+\+)['" ]}
 | 
			
		||||
      problem "Use \"\#{ENV.cxx}\" instead of hard-coding \"#{$3}\""
 | 
			
		||||
      problem "Use \"\#{ENV.cxx}\" instead of hard-coding \"#{Regexp.last_match(3)}\""
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    if line =~ /system\s+['"](env|export)(\s+|['"])/
 | 
			
		||||
      problem "Use ENV instead of invoking '#{$1}' to modify the environment"
 | 
			
		||||
      problem "Use ENV instead of invoking '#{Regexp.last_match(1)}' to modify the environment"
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    if formula.name != "wine" && line =~ /ENV\.universal_binary/
 | 
			
		||||
@ -1007,27 +1007,27 @@ class FormulaAuditor
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    if line =~ /build\.include\?[\s\(]+['"]\-\-(.*)['"]/
 | 
			
		||||
      problem "Reference '#{$1}' without dashes"
 | 
			
		||||
      problem "Reference '#{Regexp.last_match(1)}' without dashes"
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    if line =~ /build\.include\?[\s\(]+['"]with(out)?-(.*)['"]/
 | 
			
		||||
      problem "Use build.with#{$1}? \"#{$2}\" instead of build.include? 'with#{$1}-#{$2}'"
 | 
			
		||||
      problem "Use build.with#{Regexp.last_match(1)}? \"#{Regexp.last_match(2)}\" instead of build.include? 'with#{Regexp.last_match(1)}-#{Regexp.last_match(2)}'"
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    if line =~ /build\.with\?[\s\(]+['"]-?-?with-(.*)['"]/
 | 
			
		||||
      problem "Don't duplicate 'with': Use `build.with? \"#{$1}\"` to check for \"--with-#{$1}\""
 | 
			
		||||
      problem "Don't duplicate 'with': Use `build.with? \"#{Regexp.last_match(1)}\"` to check for \"--with-#{Regexp.last_match(1)}\""
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    if line =~ /build\.without\?[\s\(]+['"]-?-?without-(.*)['"]/
 | 
			
		||||
      problem "Don't duplicate 'without': Use `build.without? \"#{$1}\"` to check for \"--without-#{$1}\""
 | 
			
		||||
      problem "Don't duplicate 'without': Use `build.without? \"#{Regexp.last_match(1)}\"` to check for \"--without-#{Regexp.last_match(1)}\""
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    if line =~ /unless build\.with\?(.*)/
 | 
			
		||||
      problem "Use if build.without?#{$1} instead of unless build.with?#{$1}"
 | 
			
		||||
      problem "Use if build.without?#{Regexp.last_match(1)} instead of unless build.with?#{Regexp.last_match(1)}"
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    if line =~ /unless build\.without\?(.*)/
 | 
			
		||||
      problem "Use if build.with?#{$1} instead of unless build.without?#{$1}"
 | 
			
		||||
      problem "Use if build.with?#{Regexp.last_match(1)} instead of unless build.without?#{Regexp.last_match(1)}"
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    if line =~ /(not\s|!)\s*build\.with?\?/
 | 
			
		||||
@ -1071,7 +1071,7 @@ class FormulaAuditor
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    if line =~ /^def (\w+).*$/
 | 
			
		||||
      problem "Define method #{$1.inspect} in the class body, not at the top-level"
 | 
			
		||||
      problem "Define method #{Regexp.last_match(1).inspect} in the class body, not at the top-level"
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    if line.include?("ENV.fortran") && !formula.requirements.map(&:class).include?(FortranRequirement)
 | 
			
		||||
@ -1083,20 +1083,20 @@ class FormulaAuditor
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    if line =~ /depends_on :(.+) (if.+|unless.+)$/
 | 
			
		||||
      conditional_dep_problems($1.to_sym, $2, $&)
 | 
			
		||||
      conditional_dep_problems(Regexp.last_match(1).to_sym, Regexp.last_match(2), $&)
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    if line =~ /depends_on ['"](.+)['"] (if.+|unless.+)$/
 | 
			
		||||
      conditional_dep_problems($1, $2, $&)
 | 
			
		||||
      conditional_dep_problems(Regexp.last_match(1), Regexp.last_match(2), $&)
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    if line =~ /(Dir\[("[^\*{},]+")\])/
 | 
			
		||||
      problem "#{$1} is unnecessary; just use #{$2}"
 | 
			
		||||
      problem "#{Regexp.last_match(1)} is unnecessary; just use #{Regexp.last_match(2)}"
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    if line =~ /system (["'](#{FILEUTILS_METHODS})["' ])/o
 | 
			
		||||
      system = $1
 | 
			
		||||
      method = $2
 | 
			
		||||
      system = Regexp.last_match(1)
 | 
			
		||||
      method = Regexp.last_match(2)
 | 
			
		||||
      problem "Use the `#{method}` Ruby method instead of `system #{system}`"
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
@ -1114,7 +1114,7 @@ class FormulaAuditor
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    if line =~ /system\s+['"](otool|install_name_tool|lipo)/ && formula.name != "cctools"
 | 
			
		||||
      problem "Use ruby-macho instead of calling #{$1}"
 | 
			
		||||
      problem "Use ruby-macho instead of calling #{Regexp.last_match(1)}"
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    if formula.tap.to_s == "homebrew/core"
 | 
			
		||||
@ -1125,29 +1125,29 @@ class FormulaAuditor
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    if line =~ /((revision|version_scheme)\s+0)/
 | 
			
		||||
      problem "'#{$1}' should be removed"
 | 
			
		||||
      problem "'#{Regexp.last_match(1)}' should be removed"
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    return unless @strict
 | 
			
		||||
 | 
			
		||||
    problem "`#{$1}` in formulae is deprecated" if line =~ /(env :(std|userpaths))/
 | 
			
		||||
    problem "`#{Regexp.last_match(1)}` in formulae is deprecated" if line =~ /(env :(std|userpaths))/
 | 
			
		||||
 | 
			
		||||
    if line =~ /system ((["'])[^"' ]*(?:\s[^"' ]*)+\2)/
 | 
			
		||||
      bad_system = $1
 | 
			
		||||
      bad_system = Regexp.last_match(1)
 | 
			
		||||
      unless %w[| < > & ; *].any? { |c| bad_system.include? c }
 | 
			
		||||
        good_system = bad_system.gsub(" ", "\", \"")
 | 
			
		||||
        problem "Use `system #{good_system}` instead of `system #{bad_system}` "
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    problem "`#{$1}` is now unnecessary" if line =~ /(require ["']formula["'])/
 | 
			
		||||
    problem "`#{Regexp.last_match(1)}` is now unnecessary" if line =~ /(require ["']formula["'])/
 | 
			
		||||
 | 
			
		||||
    if line =~ %r{#\{share\}/#{Regexp.escape(formula.name)}[/'"]}
 | 
			
		||||
      problem "Use \#{pkgshare} instead of \#{share}/#{formula.name}"
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    return unless line =~ %r{share(\s*[/+]\s*)(['"])#{Regexp.escape(formula.name)}(?:\2|/)}
 | 
			
		||||
    problem "Use pkgshare instead of (share#{$1}\"#{formula.name}\")"
 | 
			
		||||
    problem "Use pkgshare instead of (share#{Regexp.last_match(1)}\"#{formula.name}\")"
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def audit_reverse_migration
 | 
			
		||||
@ -1297,7 +1297,7 @@ class ResourceAuditor
 | 
			
		||||
 | 
			
		||||
  def audit_download_strategy
 | 
			
		||||
    if url =~ %r{^(cvs|bzr|hg|fossil)://} || url =~ %r{^(svn)\+http://}
 | 
			
		||||
      problem "Use of the #{$&} scheme is deprecated, pass `:using => :#{$1}` instead"
 | 
			
		||||
      problem "Use of the #{$&} scheme is deprecated, pass `:using => :#{Regexp.last_match(1)}` instead"
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    url_strategy = DownloadStrategyDetector.detect(url)
 | 
			
		||||
@ -1341,7 +1341,7 @@ class ResourceAuditor
 | 
			
		||||
  def audit_urls
 | 
			
		||||
    # Check GNU urls; doesn't apply to mirrors
 | 
			
		||||
    if url =~ %r{^(?:https?|ftp)://ftpmirror.gnu.org/(.*)}
 | 
			
		||||
      problem "Please use \"https://ftp.gnu.org/gnu/#{$1}\" instead of #{url}."
 | 
			
		||||
      problem "Please use \"https://ftp.gnu.org/gnu/#{Regexp.last_match(1)}\" instead of #{url}."
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    if mirrors.include?(url)
 | 
			
		||||
@ -1375,11 +1375,11 @@ class ResourceAuditor
 | 
			
		||||
           %r{^http://(?:[^/]*\.)?mirrorservice\.org/}
 | 
			
		||||
        problem "Please use https:// for #{p}"
 | 
			
		||||
      when %r{^http://search\.mcpan\.org/CPAN/(.*)}i
 | 
			
		||||
        problem "#{p} should be `https://cpan.metacpan.org/#{$1}`"
 | 
			
		||||
        problem "#{p} should be `https://cpan.metacpan.org/#{Regexp.last_match(1)}`"
 | 
			
		||||
      when %r{^(http|ftp)://ftp\.gnome\.org/pub/gnome/(.*)}i
 | 
			
		||||
        problem "#{p} should be `https://download.gnome.org/#{$2}`"
 | 
			
		||||
        problem "#{p} should be `https://download.gnome.org/#{Regexp.last_match(2)}`"
 | 
			
		||||
      when %r{^git://anonscm\.debian\.org/users/(.*)}i
 | 
			
		||||
        problem "#{p} should be `https://anonscm.debian.org/git/users/#{$1}`"
 | 
			
		||||
        problem "#{p} should be `https://anonscm.debian.org/git/users/#{Regexp.last_match(1)}`"
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
@ -1389,7 +1389,7 @@ class ResourceAuditor
 | 
			
		||||
      when %r{^ftp://ftp\.mirrorservice\.org}
 | 
			
		||||
        problem "Please use https:// for #{p}"
 | 
			
		||||
      when %r{^ftp://ftp\.cpan\.org/pub/CPAN(.*)}i
 | 
			
		||||
        problem "#{p} should be `http://search.cpan.org/CPAN#{$1}`"
 | 
			
		||||
        problem "#{p} should be `http://search.cpan.org/CPAN#{Regexp.last_match(1)}`"
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
@ -1403,7 +1403,7 @@ class ResourceAuditor
 | 
			
		||||
      next unless p =~ %r{^https?://.*\b(sourceforge|sf)\.(com|net)}
 | 
			
		||||
 | 
			
		||||
      if p =~ /(\?|&)use_mirror=/
 | 
			
		||||
        problem "Don't use #{$1}use_mirror in SourceForge urls (url is #{p})."
 | 
			
		||||
        problem "Don't use #{Regexp.last_match(1)}use_mirror in SourceForge urls (url is #{p})."
 | 
			
		||||
      end
 | 
			
		||||
 | 
			
		||||
      if p.end_with?("/download")
 | 
			
		||||
@ -1433,7 +1433,7 @@ class ResourceAuditor
 | 
			
		||||
      problem <<-EOS.undent
 | 
			
		||||
        Please use a secure mirror for Debian URLs.
 | 
			
		||||
        We recommend:
 | 
			
		||||
          https://mirrors.ocf.berkeley.edu/debian/#{$1}
 | 
			
		||||
          https://mirrors.ocf.berkeley.edu/debian/#{Regexp.last_match(1)}
 | 
			
		||||
      EOS
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
@ -1486,7 +1486,7 @@ class ResourceAuditor
 | 
			
		||||
      next unless u =~ %r{https?://codeload\.github\.com/(.+)/(.+)/(?:tar\.gz|zip)/(.+)}
 | 
			
		||||
      problem <<-EOS.undent
 | 
			
		||||
        use GitHub archive URLs:
 | 
			
		||||
          https://github.com/#{$1}/#{$2}/archive/#{$3}.tar.gz
 | 
			
		||||
          https://github.com/#{Regexp.last_match(1)}/#{Regexp.last_match(2)}/archive/#{Regexp.last_match(3)}.tar.gz
 | 
			
		||||
        Rather than codeload:
 | 
			
		||||
          #{u}
 | 
			
		||||
      EOS
 | 
			
		||||
@ -1495,7 +1495,7 @@ class ResourceAuditor
 | 
			
		||||
    # Check for Maven Central urls, prefer HTTPS redirector over specific host
 | 
			
		||||
    urls.each do |u|
 | 
			
		||||
      next unless u =~ %r{https?://(?:central|repo\d+)\.maven\.org/maven2/(.+)$}
 | 
			
		||||
      problem "#{u} should be `https://search.maven.org/remotecontent?filepath=#{$1}`"
 | 
			
		||||
      problem "#{u} should be `https://search.maven.org/remotecontent?filepath=#{Regexp.last_match(1)}`"
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    if name == "curl" && !urls.find { |u| u.start_with?("http://") }
 | 
			
		||||
@ -1506,7 +1506,7 @@ class ResourceAuditor
 | 
			
		||||
    if @strict
 | 
			
		||||
      urls.each do |p|
 | 
			
		||||
        next unless p =~ %r{^https?://pypi.python.org/(.*)}
 | 
			
		||||
        problem "#{p} should be `https://files.pythonhosted.org/#{$1}`"
 | 
			
		||||
        problem "#{p} should be `https://files.pythonhosted.org/#{Regexp.last_match(1)}`"
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -101,13 +101,13 @@ class FormulaCreator
 | 
			
		||||
    if @name.nil?
 | 
			
		||||
      case url
 | 
			
		||||
      when %r{github\.com/(\S+)/(\S+)\.git}
 | 
			
		||||
        @user = $1
 | 
			
		||||
        @name = $2
 | 
			
		||||
        @user = Regexp.last_match(1)
 | 
			
		||||
        @name = Regexp.last_match(2)
 | 
			
		||||
        @head = true
 | 
			
		||||
        @github = true
 | 
			
		||||
      when %r{github\.com/(\S+)/(\S+)/(archive|releases)/}
 | 
			
		||||
        @user = $1
 | 
			
		||||
        @name = $2
 | 
			
		||||
        @user = Regexp.last_match(1)
 | 
			
		||||
        @name = Regexp.last_match(2)
 | 
			
		||||
        @github = true
 | 
			
		||||
      else
 | 
			
		||||
        @name = path.basename.to_s[/(.*?)[-_.]?#{Regexp.escape(path.version.to_s)}/, 1]
 | 
			
		||||
 | 
			
		||||
@ -87,7 +87,7 @@ module Homebrew
 | 
			
		||||
    date = if ARGV.include?("--fail-if-changed") &&
 | 
			
		||||
              target.extname == ".1" && target.exist?
 | 
			
		||||
      /"(\d{1,2})" "([A-Z][a-z]+) (\d{4})" "#{organisation}" "#{manual}"/ =~ target.read
 | 
			
		||||
      Date.parse("#{$1} #{$2} #{$3}")
 | 
			
		||||
      Date.parse("#{Regexp.last_match(1)} #{Regexp.last_match(2)} #{Regexp.last_match(3)}")
 | 
			
		||||
    else
 | 
			
		||||
      Date.today
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
@ -347,7 +347,7 @@ module Homebrew
 | 
			
		||||
    formulae = []
 | 
			
		||||
    others = []
 | 
			
		||||
    File.foreach(patchfile) do |line|
 | 
			
		||||
      files << $1 if line =~ %r{^\+\+\+ b/(.*)}
 | 
			
		||||
      files << Regexp.last_match(1) if line =~ %r{^\+\+\+ b/(.*)}
 | 
			
		||||
    end
 | 
			
		||||
    files.each do |file|
 | 
			
		||||
      if tap && tap.formula_file?(file)
 | 
			
		||||
 | 
			
		||||
@ -33,7 +33,7 @@ module Homebrew
 | 
			
		||||
    if ARGV.include?("--markdown")
 | 
			
		||||
      output.map! do |s|
 | 
			
		||||
        /(.*\d)+ \(@(.+)\) - (.*)/ =~ s
 | 
			
		||||
        "- [#{$3}](#{$1}) (@#{$2})"
 | 
			
		||||
        "- [#{Regexp.last_match(3)}](#{Regexp.last_match(1)}) (@#{Regexp.last_match(2)})"
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -49,7 +49,7 @@ module Homebrew
 | 
			
		||||
            case line.chomp
 | 
			
		||||
              # regex matches: /dev/disk0s2   489562928 440803616  48247312    91%    /
 | 
			
		||||
            when /^.+\s+[0-9]+\s+[0-9]+\s+[0-9]+\s+[0-9]{1,3}%\s+(.+)/
 | 
			
		||||
              vols << $1
 | 
			
		||||
              vols << Regexp.last_match(1)
 | 
			
		||||
            end
 | 
			
		||||
          end
 | 
			
		||||
        end
 | 
			
		||||
@ -919,11 +919,11 @@ module Homebrew
 | 
			
		||||
        return unless which "python"
 | 
			
		||||
        `python -V 2>&1` =~ /Python (\d+)\./
 | 
			
		||||
        # This won't be the right warning if we matched nothing at all
 | 
			
		||||
        return if $1.nil?
 | 
			
		||||
        return if $1 == "2"
 | 
			
		||||
        return if Regexp.last_match(1).nil?
 | 
			
		||||
        return if Regexp.last_match(1) == "2"
 | 
			
		||||
 | 
			
		||||
        <<-EOS.undent
 | 
			
		||||
          python is symlinked to python#{$1}
 | 
			
		||||
          python is symlinked to python#{Regexp.last_match(1)}
 | 
			
		||||
          This will confuse build scripts and in general lead to subtle breakage.
 | 
			
		||||
        EOS
 | 
			
		||||
      end
 | 
			
		||||
 | 
			
		||||
@ -517,8 +517,8 @@ class S3DownloadStrategy < CurlDownloadStrategy
 | 
			
		||||
    if @url !~ %r{^https?://([^.].*)\.s3\.amazonaws\.com/(.+)$}
 | 
			
		||||
      raise "Bad S3 URL: " + @url
 | 
			
		||||
    end
 | 
			
		||||
    bucket = $1
 | 
			
		||||
    key = $2
 | 
			
		||||
    bucket = Regexp.last_match(1)
 | 
			
		||||
    key = Regexp.last_match(2)
 | 
			
		||||
 | 
			
		||||
    ENV["AWS_ACCESS_KEY_ID"] = ENV["HOMEBREW_AWS_ACCESS_KEY_ID"]
 | 
			
		||||
    ENV["AWS_SECRET_ACCESS_KEY"] = ENV["HOMEBREW_AWS_SECRET_ACCESS_KEY"]
 | 
			
		||||
 | 
			
		||||
@ -182,7 +182,7 @@ class TapFormulaAmbiguityError < RuntimeError
 | 
			
		||||
    @paths = paths
 | 
			
		||||
    @formulae = paths.map do |path|
 | 
			
		||||
      path.to_s =~ HOMEBREW_TAP_PATH_REGEX
 | 
			
		||||
      "#{Tap.fetch($1, $2)}/#{path.basename(".rb")}"
 | 
			
		||||
      "#{Tap.fetch(Regexp.last_match(1), Regexp.last_match(2))}/#{path.basename(".rb")}"
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    super <<-EOS.undent
 | 
			
		||||
@ -202,7 +202,7 @@ class TapFormulaWithOldnameAmbiguityError < RuntimeError
 | 
			
		||||
 | 
			
		||||
    @taps = possible_tap_newname_formulae.map do |newname|
 | 
			
		||||
      newname =~ HOMEBREW_TAP_FORMULA_REGEX
 | 
			
		||||
      "#{$1}/#{$2}"
 | 
			
		||||
      "#{Regexp.last_match(1)}/#{Regexp.last_match(2)}"
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    super <<-EOS.undent
 | 
			
		||||
@ -504,7 +504,7 @@ class CurlDownloadStrategyError < RuntimeError
 | 
			
		||||
  def initialize(url)
 | 
			
		||||
    case url
 | 
			
		||||
    when %r{^file://(.+)}
 | 
			
		||||
      super "File does not exist: #{$1}"
 | 
			
		||||
      super "File does not exist: #{Regexp.last_match(1)}"
 | 
			
		||||
    else
 | 
			
		||||
      super "Download failed: #{url}"
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
@ -200,7 +200,7 @@ module Stdenv
 | 
			
		||||
  # @private
 | 
			
		||||
  def set_cpu_flags(flags, default = DEFAULT_FLAGS, map = Hardware::CPU.optimization_flags)
 | 
			
		||||
    cflags =~ /(-Xarch_#{Hardware::CPU.arch_32_bit} )-march=/
 | 
			
		||||
    xarch = $1.to_s
 | 
			
		||||
    xarch = Regexp.last_match(1).to_s
 | 
			
		||||
    remove flags, /(-Xarch_#{Hardware::CPU.arch_32_bit} )?-march=\S*/
 | 
			
		||||
    remove flags, /( -Xclang \S+)+/
 | 
			
		||||
    remove flags, /-mssse3/
 | 
			
		||||
 | 
			
		||||
@ -266,7 +266,7 @@ module Superenv
 | 
			
		||||
 | 
			
		||||
  def make_jobs
 | 
			
		||||
    self["MAKEFLAGS"] =~ /-\w*j(\d+)/
 | 
			
		||||
    [$1.to_i, 1].max
 | 
			
		||||
    [Regexp.last_match(1).to_i, 1].max
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def universal_binary
 | 
			
		||||
 | 
			
		||||
@ -32,7 +32,7 @@ module Utils
 | 
			
		||||
      # :tiger_g4, :tiger_g5, etc.
 | 
			
		||||
      def find_altivec_tag(tag)
 | 
			
		||||
        return unless tag.to_s =~ /(\w+)_(g4|g4e|g5)$/
 | 
			
		||||
        altivec_tag = "#{$1}_altivec".to_sym
 | 
			
		||||
        altivec_tag = "#{Regexp.last_match(1)}_altivec".to_sym
 | 
			
		||||
        altivec_tag if key?(altivec_tag)
 | 
			
		||||
      end
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -177,7 +177,7 @@ class Formula
 | 
			
		||||
    @tap = if path == Formulary.core_path(name)
 | 
			
		||||
      CoreTap.instance
 | 
			
		||||
    elsif path.to_s =~ HOMEBREW_TAP_PATH_REGEX
 | 
			
		||||
      Tap.fetch($1, $2)
 | 
			
		||||
      Tap.fetch(Regexp.last_match(1), Regexp.last_match(2))
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    @full_name = full_name_with_optional_tap(name)
 | 
			
		||||
 | 
			
		||||
@ -59,7 +59,7 @@ module Formulary
 | 
			
		||||
 | 
			
		||||
  def self.class_s(name)
 | 
			
		||||
    class_name = name.capitalize
 | 
			
		||||
    class_name.gsub!(/[-_.\s]([a-zA-Z0-9])/) { $1.upcase }
 | 
			
		||||
    class_name.gsub!(/[-_.\s]([a-zA-Z0-9])/) { Regexp.last_match(1).upcase }
 | 
			
		||||
    class_name.tr!("+", "x")
 | 
			
		||||
    class_name.sub!(/(.)@(\d)/, "\\1AT\\2")
 | 
			
		||||
    class_name
 | 
			
		||||
@ -168,7 +168,7 @@ module Formulary
 | 
			
		||||
      super
 | 
			
		||||
    rescue MethodDeprecatedError => e
 | 
			
		||||
      if url =~ %r{github.com/([\w-]+)/homebrew-([\w-]+)/}
 | 
			
		||||
        e.issues_url = "https://github.com/#{$1}/homebrew-#{$2}/issues/new"
 | 
			
		||||
        e.issues_url = "https://github.com/#{Regexp.last_match(1)}/homebrew-#{Regexp.last_match(2)}/issues/new"
 | 
			
		||||
      end
 | 
			
		||||
      raise
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
@ -61,7 +61,7 @@ class Requirement
 | 
			
		||||
 | 
			
		||||
    if parent = satisfied_result_parent
 | 
			
		||||
      parent.to_s =~ %r{(#{Regexp.escape(HOMEBREW_CELLAR)}|#{Regexp.escape(HOMEBREW_PREFIX)}/opt)/([\w+-.@]+)}
 | 
			
		||||
      @formula = $2
 | 
			
		||||
      @formula = Regexp.last_match(2)
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    true
 | 
			
		||||
 | 
			
		||||
@ -54,7 +54,7 @@ module RuboCop
 | 
			
		||||
            problem "Please use https:// for #{homepage}"
 | 
			
		||||
 | 
			
		||||
          when %r{^http://([^/]*)\.(sf|sourceforge)\.net(/|$)}
 | 
			
		||||
            problem "#{homepage} should be `https://#{$1}.sourceforge.io/`"
 | 
			
		||||
            problem "#{homepage} should be `https://#{Regexp.last_match(1)}.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.
 | 
			
		||||
 | 
			
		||||
@ -43,8 +43,8 @@ class Tap
 | 
			
		||||
 | 
			
		||||
  def self.from_path(path)
 | 
			
		||||
    path.to_s =~ HOMEBREW_TAP_PATH_REGEX
 | 
			
		||||
    raise "Invalid tap path '#{path}'" unless $1
 | 
			
		||||
    fetch($1, $2)
 | 
			
		||||
    raise "Invalid tap path '#{path}'" unless Regexp.last_match(1)
 | 
			
		||||
    fetch(Regexp.last_match(1), Regexp.last_match(2))
 | 
			
		||||
  rescue
 | 
			
		||||
    # No need to error as a nil tap is sufficient to show failure.
 | 
			
		||||
    nil
 | 
			
		||||
 | 
			
		||||
@ -76,7 +76,7 @@ def odeprecated(method, replacement = nil, disable: false, disable_on: nil, call
 | 
			
		||||
  tap_message = nil
 | 
			
		||||
  caller_message = backtrace.detect do |line|
 | 
			
		||||
    next unless line =~ %r{^#{Regexp.escape(HOMEBREW_LIBRARY)}/Taps/([^/]+/[^/]+)/}
 | 
			
		||||
    tap = Tap.fetch $1
 | 
			
		||||
    tap = Tap.fetch Regexp.last_match(1)
 | 
			
		||||
    tap_message = "\nPlease report this to the #{tap} tap!"
 | 
			
		||||
    true
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user