diff options
Diffstat (limited to 'Library')
35 files changed, 220 insertions, 144 deletions
diff --git a/Library/.rubocop.yml b/Library/.rubocop.yml index 6fa90a4c2..293e88749 100644 --- a/Library/.rubocop.yml +++ b/Library/.rubocop.yml @@ -1,6 +1,8 @@ AllCops: TargetRubyVersion: 2.0 Exclude: + - '**/Rakefile' + - '**/.*' - '**/Casks/**/*' - '**/vendor/**/*' @@ -9,6 +11,9 @@ require: ./Homebrew/rubocops.rb FormulaAudit/Text: Enabled: true +FormulaAudit/Caveats: + Enabled: true + FormulaAuditStrict/BottleBlock: Enabled: true diff --git a/Library/Homebrew/cask/lib/hbc/cli/internal_appcast_checkpoint.rb b/Library/Homebrew/cask/lib/hbc/cli/internal_appcast_checkpoint.rb index cd2679782..ceb202bb7 100644 --- a/Library/Homebrew/cask/lib/hbc/cli/internal_appcast_checkpoint.rb +++ b/Library/Homebrew/cask/lib/hbc/cli/internal_appcast_checkpoint.rb @@ -43,7 +43,7 @@ module Hbc if checkpoint.nil? onoe "Could not retrieve `appcast` checkpoint for cask '#{cask}': #{result[:command_result].stderr}" else - puts((cask_tokens.count > 1) ? "#{checkpoint} #{cask}" : checkpoint) + puts((cask_tokens.count > 1) ? "#{checkpoint} #{cask}": checkpoint) count += 1 end end diff --git a/Library/Homebrew/cmd/list.rb b/Library/Homebrew/cmd/list.rb index f5c4e68ac..790d858aa 100644 --- a/Library/Homebrew/cmd/list.rb +++ b/Library/Homebrew/cmd/list.rb @@ -129,7 +129,7 @@ module Homebrew names.each do |d| versions = d.subdirs.map { |pn| pn.basename.to_s } next if ARGV.include?("--multiple") && versions.length < 2 - puts "#{d.basename} #{versions * " "}" + puts "#{d.basename} #{versions*" "}" end end end diff --git a/Library/Homebrew/cmd/search.rb b/Library/Homebrew/cmd/search.rb index ed438f846..f71a14ba1 100644 --- a/Library/Homebrew/cmd/search.rb +++ b/Library/Homebrew/cmd/search.rb @@ -114,7 +114,7 @@ module Homebrew def search_formulae(regex) aliases = Formula.alias_full_names - results = (Formula.full_names + aliases).grep(regex).sort + results = (Formula.full_names+aliases).grep(regex).sort results.map do |name| begin diff --git a/Library/Homebrew/cmd/switch.rb b/Library/Homebrew/cmd/switch.rb index a40b4d88e..6eed1fd96 100644 --- a/Library/Homebrew/cmd/switch.rb +++ b/Library/Homebrew/cmd/switch.rb @@ -25,7 +25,7 @@ module Homebrew end # Does the target version exist? - unless (rack/version).directory? + unless (rack+version).directory? onoe "#{name} does not have a version \"#{version}\" in the Cellar." versions = rack.subdirs.map { |d| Keg.new(d).version } @@ -41,7 +41,7 @@ module Homebrew keg.unlink end - keg = Keg.new(rack/version) + keg = Keg.new(rack+version) # Link new version, if not keg-only if keg_only?(rack) diff --git a/Library/Homebrew/debrew.rb b/Library/Homebrew/debrew.rb index 7ff2c0360..668a0b4d2 100644 --- a/Library/Homebrew/debrew.rb +++ b/Library/Homebrew/debrew.rb @@ -50,7 +50,7 @@ module Debrew choice = nil while choice.nil? - menu.entries.each_with_index { |e, i| puts "#{i + 1}. #{e.name}" } + menu.entries.each_with_index { |e, i| puts "#{i+1}. #{e.name}" } print menu.prompt unless menu.prompt.nil? input = $stdin.gets || exit @@ -58,7 +58,7 @@ module Debrew i = input.to_i if i > 0 - choice = menu.entries[i - 1] + choice = menu.entries[i-1] else possible = menu.entries.find_all { |e| e.name.start_with?(input) } diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb index 7cad704e4..bf7d2fc79 100644 --- a/Library/Homebrew/dev-cmd/audit.rb +++ b/Library/Homebrew/dev-cmd/audit.rb @@ -868,7 +868,7 @@ class FormulaAuditor def audit_lines text.without_patch.split("\n").each_with_index do |line, lineno| - line_problems(line, lineno + 1) + line_problems(line, lineno+1) end end @@ -1148,11 +1148,6 @@ class FormulaAuditor problem "Use pkgshare instead of (share#{$1}\"#{formula.name}\")" end - def audit_caveats - return unless formula.caveats.to_s.include?("setuid") - problem "Don't recommend setuid in the caveats, suggest sudo instead." - end - def audit_reverse_migration # Only enforce for new formula being re-added to core and official taps return unless @strict diff --git a/Library/Homebrew/dev-cmd/bottle.rb b/Library/Homebrew/dev-cmd/bottle.rb index d8aefc4c0..e301cc423 100644 --- a/Library/Homebrew/dev-cmd/bottle.rb +++ b/Library/Homebrew/dev-cmd/bottle.rb @@ -248,7 +248,7 @@ module Homebrew mv "#{relocatable_tar_path}.gz", bottle_path end - if bottle_path.size > 1 * 1024 * 1024 + if bottle_path.size > 1*1024*1024 ohai "Detecting if #{filename} is relocatable..." end diff --git a/Library/Homebrew/dev-cmd/edit.rb b/Library/Homebrew/dev-cmd/edit.rb index b3a319088..a8612fc63 100644 --- a/Library/Homebrew/dev-cmd/edit.rb +++ b/Library/Homebrew/dev-cmd/edit.rb @@ -24,9 +24,9 @@ module Homebrew if ["mate", "subl"].include?(editor) # If the user is using TextMate or Sublime Text, # give a nice project view instead. - exec_editor HOMEBREW_REPOSITORY/"bin/brew", - HOMEBREW_REPOSITORY/"README.md", - HOMEBREW_REPOSITORY/".gitignore", + exec_editor HOMEBREW_REPOSITORY+"bin/brew", + HOMEBREW_REPOSITORY+"README.md", + HOMEBREW_REPOSITORY+".gitignore", *library_folders else exec_editor HOMEBREW_REPOSITORY diff --git a/Library/Homebrew/development_tools.rb b/Library/Homebrew/development_tools.rb index 80de1b5dc..8f417b082 100644 --- a/Library/Homebrew/development_tools.rb +++ b/Library/Homebrew/development_tools.rb @@ -51,7 +51,7 @@ class DevelopmentTools def gcc_4_2_build_version @gcc_4_2_build_version ||= begin gcc = locate("gcc-4.2") || HOMEBREW_PREFIX.join("opt/apple-gcc42/bin/gcc-4.2") - if gcc.exist? && !gcc.realpath.basename.to_s.start_with?("llvm") && + if gcc.exist? && !gcc.realpath.basename.to_s.start_with?("llvm")&& build_version = `#{gcc} --version 2>/dev/null`[/build (\d{4,})/, 1] Version.new build_version else diff --git a/Library/Homebrew/diagnostic.rb b/Library/Homebrew/diagnostic.rb index 2741184cc..5aa4d788b 100644 --- a/Library/Homebrew/diagnostic.rb +++ b/Library/Homebrew/diagnostic.rb @@ -158,7 +158,7 @@ module Homebrew "libosxfuse_i32.2.dylib", # OSXFuse "libosxfuse_i64.2.dylib", # OSXFuse "libosxfuse.2.dylib", # OSXFuse - "libTrAPI.dylib", # TrAPI/Endpoint Security VPN + "libTrAPI.dylib", # TrAPI / Endpoint Security VPN "libntfs-3g.*.dylib", # NTFS-3G "libntfs.*.dylib", # NTFS-3G "libublio.*.dylib", # NTFS-3G @@ -470,7 +470,7 @@ module Homebrew return if $seen_prefix_sbin # Don't complain about sbin not being in the path if it doesn't exist - sbin = HOMEBREW_PREFIX/"sbin" + sbin = (HOMEBREW_PREFIX+"sbin") return unless sbin.directory? && !sbin.children.empty? <<-EOS.undent diff --git a/Library/Homebrew/download_strategy.rb b/Library/Homebrew/download_strategy.rb index 461b2ddd6..d74efe0bb 100644 --- a/Library/Homebrew/download_strategy.rb +++ b/Library/Homebrew/download_strategy.rb @@ -698,7 +698,7 @@ class SubversionDownloadStrategy < VCSDownloadStrategy end def repo_valid? - (cached_location/".svn").directory? + cached_location.join(".svn").directory? end def clone_repo @@ -711,7 +711,7 @@ class SubversionDownloadStrategy < VCSDownloadStrategy fetch_repo cached_location, @url, main_revision, true externals do |external_name, external_url| - fetch_repo cached_location/external_name, external_url, @ref[external_name], true + fetch_repo cached_location+external_name, external_url, @ref[external_name], true end else fetch_repo cached_location, @url @@ -737,7 +737,7 @@ class GitDownloadStrategy < VCSDownloadStrategy def stage super - cp_r cached_location/".", Dir.pwd, preserve: true + cp_r File.join(cached_location, "."), Dir.pwd, preserve: true end def source_modified_time @@ -781,7 +781,7 @@ class GitDownloadStrategy < VCSDownloadStrategy end def git_dir - cached_location/".git" + cached_location.join(".git") end def ref? @@ -797,7 +797,7 @@ class GitDownloadStrategy < VCSDownloadStrategy end def submodules? - (cached_location/".gitmodules").exist? + cached_location.join(".gitmodules").exist? end def clone_args @@ -977,7 +977,7 @@ class CVSDownloadStrategy < VCSDownloadStrategy end def stage - cp_r cached_location/".", Dir.pwd, preserve: true + cp_r File.join(cached_location, "."), Dir.pwd, preserve: true end private @@ -987,7 +987,7 @@ class CVSDownloadStrategy < VCSDownloadStrategy end def repo_valid? - (cached_location/"CVS").directory? + cached_location.join("CVS").directory? end def clone_repo @@ -1004,8 +1004,8 @@ class CVSDownloadStrategy < VCSDownloadStrategy def split_url(in_url) parts = in_url.split(/:/) - mod = parts.pop - url = parts.join(":") + mod=parts.pop + url=parts.join(":") [mod, url] end end @@ -1045,7 +1045,7 @@ class MercurialDownloadStrategy < VCSDownloadStrategy end def repo_valid? - (cached_location/".hg").directory? + cached_location.join(".hg").directory? end def clone_repo @@ -1066,7 +1066,7 @@ class BazaarDownloadStrategy < VCSDownloadStrategy def stage # The export command doesn't work on checkouts # See https://bugs.launchpad.net/bzr/+bug/897511 - cp_r cached_location/".", Dir.pwd, preserve: true + cp_r File.join(cached_location, "."), Dir.pwd, preserve: true rm_r ".bzr" end @@ -1085,7 +1085,7 @@ class BazaarDownloadStrategy < VCSDownloadStrategy end def repo_valid? - (cached_location/".bzr").directory? + cached_location.join(".bzr").directory? end def clone_repo diff --git a/Library/Homebrew/exceptions.rb b/Library/Homebrew/exceptions.rb index 488ef7064..5001c550d 100644 --- a/Library/Homebrew/exceptions.rb +++ b/Library/Homebrew/exceptions.rb @@ -328,7 +328,7 @@ class FormulaConflictError < RuntimeError message << "Cannot install #{formula.full_name} because conflicting formulae are installed." message.concat conflicts.map { |c| conflict_message(c) } << "" message << <<-EOS.undent - Please `brew unlink #{conflicts.map(&:name) * " "}` before continuing. + Please `brew unlink #{conflicts.map(&:name)*" "}` before continuing. Unlinking removes a formula's symlinks from #{HOMEBREW_PREFIX}. You can link the formula again after the install finishes. You can --force this diff --git a/Library/Homebrew/extend/ARGV.rb b/Library/Homebrew/extend/ARGV.rb index c6cb54f5d..8cc2ccbc0 100644 --- a/Library/Homebrew/extend/ARGV.rb +++ b/Library/Homebrew/extend/ARGV.rb @@ -138,7 +138,7 @@ module HomebrewArgvExtension end def next - at(@n + 1) || raise(UsageError) + at(@n+1) || raise(UsageError) end def value(name) diff --git a/Library/Homebrew/extend/ENV/std.rb b/Library/Homebrew/extend/ENV/std.rb index 4a871f9bb..91189f53a 100644 --- a/Library/Homebrew/extend/ENV/std.rb +++ b/Library/Homebrew/extend/ENV/std.rb @@ -98,7 +98,7 @@ module Stdenv # @private def determine_cxx dir, base = determine_cc.split - dir/base.to_s.sub("gcc", "g++").sub("clang", "clang++") + dir / base.to_s.sub("gcc", "g++").sub("clang", "clang++") end def gcc_4_0 diff --git a/Library/Homebrew/extend/os/mac/extend/ENV/std.rb b/Library/Homebrew/extend/os/mac/extend/ENV/std.rb index dd273cfbc..4853ecf0c 100644 --- a/Library/Homebrew/extend/os/mac/extend/ENV/std.rb +++ b/Library/Homebrew/extend/os/mac/extend/ENV/std.rb @@ -7,7 +7,7 @@ module Stdenv # Mountain Lion's sed is stricter, and errors out when # it encounters files with mixed character sets delete("LC_ALL") - self["LC_CTYPE"] = "C" + self["LC_CTYPE"]="C" end # Add lib and include etc. from the current macosxsdk to compiler flags: diff --git a/Library/Homebrew/extend/pathname.rb b/Library/Homebrew/extend/pathname.rb index 767d83ff9..93b1c720b 100644 --- a/Library/Homebrew/extend/pathname.rb +++ b/Library/Homebrew/extend/pathname.rb @@ -246,7 +246,7 @@ class Pathname rmdir true rescue Errno::ENOTEMPTY - if (ds_store = join(".DS_Store")).exist? && children.length == 1 + if (ds_store = self+".DS_Store").exist? && children.length == 1 ds_store.unlink retry else @@ -343,7 +343,7 @@ class Pathname # @private def resolved_path - symlink? ? dirname.join(readlink) : self + symlink? ? dirname+readlink : self end # @private @@ -353,7 +353,7 @@ class Pathname # The link target contains NUL bytes false else - dirname.join(link).exist? + (dirname+link).exist? end # @private @@ -367,7 +367,7 @@ class Pathname if !other.respond_to?(:to_str) && !other.respond_to?(:to_path) odeprecated "Pathname#/ with #{other.class}", "a String or a Pathname" end - join(other.to_s) + self + other.to_s end end @@ -403,7 +403,7 @@ class Pathname mkpath targets.each do |target| target = Pathname.new(target) # allow pathnames or strings - join(target.basename).write <<-EOS.undent + (self+target.basename).write <<-EOS.undent #!/bin/bash exec "#{target}" "$@" EOS @@ -427,7 +427,7 @@ class Pathname Pathname.glob("#{self}/*") do |file| next if file.directory? dst.install(file) - new_file = dst.join(file.basename) + new_file = dst+file.basename file.write_env_script(new_file, env) end end @@ -435,7 +435,7 @@ class Pathname # Writes an exec script that invokes a java jar def write_jar_script(target_jar, script_name, java_opts = "") mkpath - join(script_name).write <<-EOS.undent + (self+script_name).write <<-EOS.undent #!/bin/bash exec java #{java_opts} -jar #{target_jar} "$@" EOS diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index b50f76668..52702eaca 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -621,14 +621,14 @@ class Formula # No `make install` available? # <pre>bin.install "binary1"</pre> def bin - prefix/"bin" + prefix+"bin" end # The directory where the formula's documentation should be installed. # This is symlinked into `HOMEBREW_PREFIX` after installation or with # `brew link` for formulae that are not keg-only. def doc - share/"doc"/name + share+"doc"+name end # The directory where the formula's headers should be installed. @@ -638,14 +638,14 @@ class Formula # No `make install` available? # <pre>include.install "example.h"</pre> def include - prefix/"include" + prefix+"include" end # The directory where the formula's info files should be installed. # This is symlinked into `HOMEBREW_PREFIX` after installation or with # `brew link` for formulae that are not keg-only. def info - share/"info" + share+"info" end # The directory where the formula's libraries should be installed. @@ -655,7 +655,7 @@ class Formula # No `make install` available? # <pre>lib.install "example.dylib"</pre> def lib - prefix/"lib" + prefix+"lib" end # The directory where the formula's binaries should be installed. @@ -664,7 +664,7 @@ class Formula # symlinked into HOMEBREW_PREFIX from one of the other directories and # instead manually create symlinks or wrapper scripts into e.g. {#bin}. def libexec - prefix/"libexec" + prefix+"libexec" end # The root directory where the formula's manual pages should be installed. @@ -673,7 +673,7 @@ class Formula # Often one of the more specific `man` functions should be used instead # e.g. {#man1} def man - share/"man" + share+"man" end # The directory where the formula's man1 pages should be installed. @@ -683,14 +683,14 @@ class Formula # No `make install` available? # <pre>man1.install "example.1"</pre> def man1 - man/"man1" + man+"man1" end # The directory where the formula's man2 pages should be installed. # This is symlinked into `HOMEBREW_PREFIX` after installation or with # `brew link` for formulae that are not keg-only. def man2 - man/"man2" + man+"man2" end # The directory where the formula's man3 pages should be installed. @@ -700,42 +700,42 @@ class Formula # No `make install` available? # <pre>man3.install "man.3"</pre> def man3 - man/"man3" + man+"man3" end # The directory where the formula's man4 pages should be installed. # This is symlinked into `HOMEBREW_PREFIX` after installation or with # `brew link` for formulae that are not keg-only. def man4 - man/"man4" + man+"man4" end # The directory where the formula's man5 pages should be installed. # This is symlinked into `HOMEBREW_PREFIX` after installation or with # `brew link` for formulae that are not keg-only. def man5 - man/"man5" + man+"man5" end # The directory where the formula's man6 pages should be installed. # This is symlinked into `HOMEBREW_PREFIX` after installation or with # `brew link` for formulae that are not keg-only. def man6 - man/"man6" + man+"man6" end # The directory where the formula's man7 pages should be installed. # This is symlinked into `HOMEBREW_PREFIX` after installation or with # `brew link` for formulae that are not keg-only. def man7 - man/"man7" + man+"man7" end # The directory where the formula's man8 pages should be installed. # This is symlinked into `HOMEBREW_PREFIX` after installation or with # `brew link` for formulae that are not keg-only. def man8 - man/"man8" + man+"man8" end # The directory where the formula's `sbin` binaries should be installed. @@ -743,7 +743,7 @@ class Formula # `brew link` for formulae that are not keg-only. # Generally we try to migrate these to {#bin} instead. def sbin - prefix/"sbin" + prefix+"sbin" end # The directory where the formula's shared files should be installed. @@ -762,7 +762,7 @@ class Formula # Install `./example_code/simple/ones` to share/demos/examples # <pre>(share/"demos").install "example_code/simple/ones" => "examples"</pre> def share - prefix/"share" + prefix+"share" end # The directory where the formula's shared files should be installed, @@ -773,7 +773,7 @@ class Formula # No `make install` available? # <pre>pkgshare.install "examples"</pre> def pkgshare - prefix/"share"/name + prefix+"share"+name end # The directory where Emacs Lisp files should be installed, with the @@ -782,7 +782,7 @@ class Formula # Install an Emacs mode included with a software package: # <pre>elisp.install "contrib/emacs/example-mode.el"</pre> def elisp - prefix/"share/emacs/site-lisp"/name + prefix+"share/emacs/site-lisp"+name end # The directory where the formula's Frameworks should be installed. @@ -790,7 +790,7 @@ class Formula # `brew link` for formulae that are not keg-only. # This is not symlinked into `HOMEBREW_PREFIX`. def frameworks - prefix/"Frameworks" + prefix+"Frameworks" end # The directory where the formula's kernel extensions should be installed. @@ -798,7 +798,7 @@ class Formula # `brew link` for formulae that are not keg-only. # This is not symlinked into `HOMEBREW_PREFIX`. def kext_prefix - prefix/"Library/Extensions" + prefix+"Library/Extensions" end # The directory where the formula's configuration files should be installed. @@ -807,14 +807,14 @@ class Formula # This directory is not inside the `HOMEBREW_CELLAR` so it is persisted # across upgrades. def etc - (HOMEBREW_PREFIX/"etc").extend(InstallRenamed) + (HOMEBREW_PREFIX+"etc").extend(InstallRenamed) end # The directory where the formula's variable files should be installed. # This directory is not inside the `HOMEBREW_CELLAR` so it is persisted # across upgrades. def var - HOMEBREW_PREFIX/"var" + HOMEBREW_PREFIX+"var" end # The directory where the formula's ZSH function files should be @@ -822,7 +822,7 @@ class Formula # This is symlinked into `HOMEBREW_PREFIX` after installation or with # `brew link` for formulae that are not keg-only. def zsh_function - share/"zsh/site-functions" + share+"zsh/site-functions" end # The directory where the formula's fish function files should be @@ -830,7 +830,7 @@ class Formula # This is symlinked into `HOMEBREW_PREFIX` after installation or with # `brew link` for formulae that are not keg-only. def fish_function - share/"fish/vendor_functions.d" + share+"fish/vendor_functions.d" end # The directory where the formula's Bash completion files should be @@ -838,7 +838,7 @@ class Formula # This is symlinked into `HOMEBREW_PREFIX` after installation or with # `brew link` for formulae that are not keg-only. def bash_completion - prefix/"etc/bash_completion.d" + prefix+"etc/bash_completion.d" end # The directory where the formula's ZSH completion files should be @@ -846,7 +846,7 @@ class Formula # This is symlinked into `HOMEBREW_PREFIX` after installation or with # `brew link` for formulae that are not keg-only. def zsh_completion - share/"zsh/site-functions" + share+"zsh/site-functions" end # The directory where the formula's fish completion files should be @@ -854,7 +854,7 @@ class Formula # This is symlinked into `HOMEBREW_PREFIX` after installation or with # `brew link` for formulae that are not keg-only. def fish_completion - share/"fish/vendor_completions.d" + share+"fish/vendor_completions.d" end # The directory used for as the prefix for {#etc} and {#var} files on @@ -862,13 +862,13 @@ class Formula # there after pouring a bottle. # @private def bottle_prefix - prefix/".bottle" + prefix+".bottle" end # The directory where the formula's installation or test logs will be written. # @private def logs - HOMEBREW_LOGS + name + HOMEBREW_LOGS+name end # The prefix, if any, to use in filenames for logging current activity @@ -921,12 +921,12 @@ class Formula # The generated launchd {.plist} service name. def plist_name - "homebrew.mxcl." + name + "homebrew.mxcl."+name end # The generated launchd {.plist} file path. def plist_path - prefix + (plist_name + ".plist") + prefix+(plist_name+".plist") end # @private @@ -951,39 +951,39 @@ class Formula end def opt_bin - opt_prefix/"bin" + opt_prefix+"bin" end def opt_include - opt_prefix/"include" + opt_prefix+"include" end def opt_lib - opt_prefix/"lib" + opt_prefix+"lib" end def opt_libexec - opt_prefix/"libexec" + opt_prefix+"libexec" end def opt_sbin - opt_prefix/"sbin" + opt_prefix+"sbin" end def opt_share - opt_prefix/"share" + opt_prefix+"share" end def opt_pkgshare - opt_prefix/"share"/name + opt_prefix+"share"+name end def opt_elisp - opt_prefix/"share/emacs/site-lisp"/name + opt_prefix+"share/emacs/site-lisp"+name end def opt_frameworks - opt_prefix/"Frameworks" + opt_prefix+"Frameworks" end # Indicates that this formula supports bottles. (Not necessarily that one @@ -1787,7 +1787,7 @@ class Formula pretty_args[i] = "import setuptools..." end end - ohai "#{cmd} #{pretty_args * " "}".strip + ohai "#{cmd} #{pretty_args*" "}".strip @exec_count ||= 0 @exec_count += 1 diff --git a/Library/Homebrew/formula_cellar_checks.rb b/Library/Homebrew/formula_cellar_checks.rb index 4718fc1a0..3dbd1b9c4 100644 --- a/Library/Homebrew/formula_cellar_checks.rb +++ b/Library/Homebrew/formula_cellar_checks.rb @@ -20,7 +20,7 @@ module FormulaCellarChecks def check_manpages # Check for man pages that aren't in share/man - return unless (formula.prefix/"man").directory? + return unless (formula.prefix+"man").directory? <<-EOS.undent A top-level "man" directory was found @@ -31,7 +31,7 @@ module FormulaCellarChecks def check_infopages # Check for info pages that aren't in share/info - return unless (formula.prefix/"info").directory? + return unless (formula.prefix+"info").directory? <<-EOS.undent A top-level "info" directory was found diff --git a/Library/Homebrew/formula_installer.rb b/Library/Homebrew/formula_installer.rb index 4287fe387..424ba34ef 100644 --- a/Library/Homebrew/formula_installer.rb +++ b/Library/Homebrew/formula_installer.rb @@ -197,7 +197,7 @@ class FormulaInstaller return if pinned_unsatisfied_deps.empty? raise CannotInstallFormulaError, - "You must `brew unpin #{pinned_unsatisfied_deps * " "}` as installing #{formula.full_name} requires the latest version of pinned dependencies" + "You must `brew unpin #{pinned_unsatisfied_deps*" "}` as installing #{formula.full_name} requires the latest version of pinned dependencies" end def build_bottle_preinstall diff --git a/Library/Homebrew/keg.rb b/Library/Homebrew/keg.rb index c2e68e908..21e1ab66f 100644 --- a/Library/Homebrew/keg.rb +++ b/Library/Homebrew/keg.rb @@ -568,7 +568,7 @@ class Keg # symlinks the contents of path+relative_dir recursively into #{HOMEBREW_PREFIX}/relative_dir def link_dir(relative_dir, mode) - root = path/relative_dir + root = path+relative_dir return unless root.exist? root.find do |src| next if src == root diff --git a/Library/Homebrew/language/node.rb b/Library/Homebrew/language/node.rb index ab2206a5b..b9abaea54 100644 --- a/Library/Homebrew/language/node.rb +++ b/Library/Homebrew/language/node.rb @@ -4,6 +4,17 @@ module Language "cache=#{HOMEBREW_CACHE}/npm_cache\n" end + def self.pack_for_installation + # Homebrew assumes the buildpath/testpath will always be disposable + # and from npm 5.0.0 the logic changed so that when a directory is + # fed to `npm install` only symlinks are created linking back to that + # directory, consequently breaking that assumption. We require a tarball + # because npm install creates a "real" installation when fed a tarball. + output = Utils.popen_read("npm pack").chomp + raise "npm failed to pack #{Dir.pwd}" unless $?.exitstatus.zero? + output + end + def self.setup_npm_environment npmrc = Pathname.new("#{ENV["HOME"]}/.npmrc") # only run setup_npm_environment once per formula @@ -14,7 +25,7 @@ module Language npmrc.write npm_cache_config # explicitly use our npm and node-gyp executables instead of the user # managed ones in HOMEBREW_PREFIX/lib/node_modules which might be broken - ENV.prepend_path "PATH", Formula["node"].opt_libexec/"npm/bin" + ENV.prepend_path "PATH", Formula["node"].opt_libexec/"bin" end def self.std_npm_install_args(libexec) @@ -22,8 +33,16 @@ module Language # tell npm to not install .brew_home by adding it to the .npmignore file # (or creating a new one if no .npmignore file already exists) open(".npmignore", "a") { |f| f.write("\n.brew_home\n") } + + pack = pack_for_installation + # npm install args for global style module format installed into libexec - ["--verbose", "--global", "--prefix=#{libexec}", "."] + %W[ + --verbose + --global + --prefix=#{libexec} + #{Dir.pwd}/#{pack} + ] end def self.local_npm_install_args diff --git a/Library/Homebrew/os/mac/architecture_list.rb b/Library/Homebrew/os/mac/architecture_list.rb index 6f498c51f..595c8f169 100644 --- a/Library/Homebrew/os/mac/architecture_list.rb +++ b/Library/Homebrew/os/mac/architecture_list.rb @@ -28,12 +28,12 @@ module ArchitectureListExtension end def ppc? - (Hardware::CPU::PPC_32BIT_ARCHS + Hardware::CPU::PPC_64BIT_ARCHS).any? { |a| include? a } + (Hardware::CPU::PPC_32BIT_ARCHS+Hardware::CPU::PPC_64BIT_ARCHS).any? { |a| include? a } end # @private def remove_ppc! - (Hardware::CPU::PPC_32BIT_ARCHS + Hardware::CPU::PPC_64BIT_ARCHS).each { |a| delete a } + (Hardware::CPU::PPC_32BIT_ARCHS+Hardware::CPU::PPC_64BIT_ARCHS).each { |a| delete a } end def as_arch_flags diff --git a/Library/Homebrew/requirements/java_requirement.rb b/Library/Homebrew/requirements/java_requirement.rb index ab6dca51d..653846edd 100644 --- a/Library/Homebrew/requirements/java_requirement.rb +++ b/Library/Homebrew/requirements/java_requirement.rb @@ -46,7 +46,7 @@ class JavaRequirement < Requirement if exact_version? @version else - @version[0, @version.length - 1] + @version[0, @version.length-1] end end diff --git a/Library/Homebrew/rubocops.rb b/Library/Homebrew/rubocops.rb index 8627d2c04..c4a38cdb7 100644 --- a/Library/Homebrew/rubocops.rb +++ b/Library/Homebrew/rubocops.rb @@ -4,3 +4,4 @@ require_relative "./rubocops/components_order_cop" require_relative "./rubocops/components_redundancy_cop" require_relative "./rubocops/homepage_cop" require_relative "./rubocops/text_cop" +require_relative "./rubocops/caveats_cop" diff --git a/Library/Homebrew/rubocops/caveats_cop.rb b/Library/Homebrew/rubocops/caveats_cop.rb new file mode 100644 index 000000000..3935d5638 --- /dev/null +++ b/Library/Homebrew/rubocops/caveats_cop.rb @@ -0,0 +1,16 @@ +require_relative "./extend/formula_cop" + +module RuboCop + module Cop + module FormulaAudit + class Caveats < FormulaCop + def audit_formula(_node, _class_node, _parent_class_node, _body_node) + caveats_strings.each do |n| + next unless regex_match_group(n, /\bsetuid\b/i) + problem "Don't recommend setuid in the caveats, suggest sudo instead." + end + end + end + end + end +end diff --git a/Library/Homebrew/rubocops/components_order_cop.rb b/Library/Homebrew/rubocops/components_order_cop.rb index a63490395..e13877ca1 100644 --- a/Library/Homebrew/rubocops/components_order_cop.rb +++ b/Library/Homebrew/rubocops/components_order_cop.rb @@ -52,9 +52,9 @@ module RuboCop end # Check if each present_components is above rest of the present_components - @present_components.take(@present_components.size - 1).each_with_index do |preceding_component, p_idx| + @present_components.take(@present_components.size-1).each_with_index do |preceding_component, p_idx| next if preceding_component.empty? - @present_components.drop(p_idx + 1).each do |succeeding_component| + @present_components.drop(p_idx+1).each do |succeeding_component| next if succeeding_component.empty? @offensive_nodes = check_precedence(preceding_component, succeeding_component) component_problem @offensive_nodes[0], @offensive_nodes[1] if @offensive_nodes @@ -88,16 +88,16 @@ module RuboCop order_idx, curr_p_idx, preceding_comp_arr = get_state(node1) # curr_p_idx > 0 means node1 needs to be grouped with its own kind - if curr_p_idx > 0 - node2 = preceding_comp_arr[curr_p_idx - 1] + if curr_p_idx>0 + node2 = preceding_comp_arr[curr_p_idx-1] indentation = " " * (start_column(node2) - line_start_column(node2)) line_breaks = node2.multiline? ? "\n\n" : "\n" - corrector.insert_after(node2.source_range, line_breaks + indentation + node1.source) + corrector.insert_after(node2.source_range, line_breaks+indentation+node1.source) else indentation = " " * (start_column(node2) - line_start_column(node2)) # No line breaks upto version_scheme, order_idx == 8 - line_breaks = (order_idx > 8) ? "\n\n" : "\n" - corrector.insert_before(node2.source_range, node1.source + line_breaks + indentation) + line_breaks = (order_idx>8) ? "\n\n" : "\n" + corrector.insert_before(node2.source_range, node1.source+line_breaks+indentation) end corrector.remove(range_with_surrounding_space(node1.source_range, :left)) end diff --git a/Library/Homebrew/rubocops/extend/formula_cop.rb b/Library/Homebrew/rubocops/extend/formula_cop.rb index d9940a037..75a3e72d5 100644 --- a/Library/Homebrew/rubocops/extend/formula_cop.rb +++ b/Library/Homebrew/rubocops/extend/formula_cop.rb @@ -24,7 +24,11 @@ module RuboCop return unless match_object node_begin_pos = start_column(node) line_begin_pos = line_start_column(node) - @column = node_begin_pos + match_object.begin(0) - line_begin_pos + 1 + if node_begin_pos == line_begin_pos + @column = node_begin_pos + match_object.begin(0) - line_begin_pos + else + @column = node_begin_pos + match_object.begin(0) - line_begin_pos + 1 + end @length = match_object.to_s.length @line_no = line_number(node) @source_buf = source_buffer(node) @@ -33,6 +37,12 @@ module RuboCop match_object end + # Returns all string nodes among the descendants of given node + def find_strings(node) + return [] if node.nil? + node.each_descendant(:str) + end + # Returns method_node matching method_name def find_node_method_by_name(node, method_name) return if node.nil? @@ -233,6 +243,11 @@ module RuboCop true end + # Return all the caveats' string nodes in an array + def caveats_strings + find_strings(find_method_def(@body, :caveats)) + end + # Returns the array of arguments of the method_node def parameters(method_node) return unless method_node.send_type? @@ -308,6 +323,8 @@ module RuboCop return node.each_child_node(:str).map(&:str_content).join("") if node.type == :dstr when :const return node.const_name if node.type == :const + else + "" end end diff --git a/Library/Homebrew/sandbox.rb b/Library/Homebrew/sandbox.rb index e2ff84ac5..2c7820d19 100644 --- a/Library/Homebrew/sandbox.rb +++ b/Library/Homebrew/sandbox.rb @@ -176,7 +176,7 @@ class Sandbox def add_rule(rule) s = "(" - s << ((rule[:allow]) ? "allow" : "deny") + s << ((rule[:allow]) ? "allow": "deny") s << " #{rule[:operation]}" s << " (#{rule[:filter]})" if rule[:filter] s << " (with #{rule[:modifier]})" if rule[:modifier] diff --git a/Library/Homebrew/test.rb b/Library/Homebrew/test.rb index d9ec8250e..ffffa1837 100644 --- a/Library/Homebrew/test.rb +++ b/Library/Homebrew/test.rb @@ -8,7 +8,7 @@ require "formula_assertions" require "fcntl" require "socket" -TEST_TIMEOUT_SECONDS = 5 * 60 +TEST_TIMEOUT_SECONDS = 5*60 begin error_pipe = UNIXSocket.open(ENV["HOMEBREW_ERROR_PIPE"], &:recv_io) diff --git a/Library/Homebrew/test/dev-cmd/audit_spec.rb b/Library/Homebrew/test/dev-cmd/audit_spec.rb index b90a21b55..25a179342 100644 --- a/Library/Homebrew/test/dev-cmd/audit_spec.rb +++ b/Library/Homebrew/test/dev-cmd/audit_spec.rb @@ -305,23 +305,6 @@ describe FormulaAuditor do end end - specify "#audit_caveats" do - fa = formula_auditor "foo", <<-EOS.undent - class Foo < Formula - homepage "http://example.com/foo" - url "http://example.com/foo-1.0.tgz" - - def caveats - "setuid" - end - end - EOS - - fa.audit_caveats - expect(fa.problems) - .to eq(["Don't recommend setuid in the caveats, suggest sudo instead."]) - end - describe "#audit_keg_only_style" do specify "keg_only_needs_downcasing" do fa = formula_auditor "foo", <<-EOS.undent, strict: true diff --git a/Library/Homebrew/test/rubocops/caveats_cop_spec.rb b/Library/Homebrew/test/rubocops/caveats_cop_spec.rb new file mode 100644 index 000000000..d44808a5d --- /dev/null +++ b/Library/Homebrew/test/rubocops/caveats_cop_spec.rb @@ -0,0 +1,42 @@ +require "rubocop" +require "rubocop/rspec/support" +require_relative "../../extend/string" +require_relative "../../rubocops/caveats_cop" + +describe RuboCop::Cop::FormulaAudit::Caveats do + subject(:cop) { described_class.new } + + context "When auditing caveats" do + it "When there is setuid mentioned in caveats" do + source = <<-EOS.undent + class Foo < Formula + homepage "http://example.com/foo" + url "http://example.com/foo-1.0.tgz" + + def caveats + "setuid" + end + end + EOS + + expected_offenses = [{ message: "Don't recommend setuid in the caveats, suggest sudo instead.", + severity: :convention, + line: 6, + column: 5, + source: source }] + + inspect_source(cop, source) + + expected_offenses.zip(cop.offenses).each do |expected, actual| + expect_offense(expected, actual) + end + end + + def expect_offense(expected, actual) + expect(actual.message).to eq(expected[:message]) + expect(actual.severity).to eq(expected[:severity]) + expect(actual.line).to eq(expected[:line]) + expect(actual.column).to eq(expected[:column]) + end + end +end diff --git a/Library/Homebrew/test/rubocops/formula_desc_cop_spec.rb b/Library/Homebrew/test/rubocops/formula_desc_cop_spec.rb index f6436d6a3..bc92291af 100644 --- a/Library/Homebrew/test/rubocops/formula_desc_cop_spec.rb +++ b/Library/Homebrew/test/rubocops/formula_desc_cop_spec.rb @@ -31,7 +31,7 @@ describe RuboCop::Cop::FormulaAuditStrict::Desc do source = <<-EOS.undent class Foo < Formula url 'http://example.com/foo-1.0.tgz' - desc '#{"bar" * 30}' + desc '#{"bar"*30}' end EOS @@ -55,8 +55,8 @@ describe RuboCop::Cop::FormulaAuditStrict::Desc do source = <<-EOS.undent class Foo < Formula url 'http://example.com/foo-1.0.tgz' - desc '#{"bar" * 10}'\ - '#{"foo" * 21}' + desc '#{"bar"*10}'\ + '#{"foo"*21}' end EOS diff --git a/Library/Homebrew/test/utils_spec.rb b/Library/Homebrew/test/utils_spec.rb index be224990a..f3bf98486 100644 --- a/Library/Homebrew/test/utils_spec.rb +++ b/Library/Homebrew/test/utils_spec.rb @@ -188,14 +188,14 @@ describe "globally-scoped helper methods" do end specify "#which_editor" do - ENV["HOMEBREW_EDITOR"] = "vemate" + ENV["HOMEBREW_EDITOR"] = "vemate -w" ENV["HOMEBREW_PATH"] = dir editor = "#{dir}/vemate" FileUtils.touch editor FileUtils.chmod 0755, editor - expect(which_editor).to eql editor + expect(which_editor).to eq("vemate -w") end specify "#gzip" do diff --git a/Library/Homebrew/utils.rb b/Library/Homebrew/utils.rb index 0c7c80281..4efcb2b4d 100644 --- a/Library/Homebrew/utils.rb +++ b/Library/Homebrew/utils.rb @@ -175,7 +175,7 @@ module Homebrew end def system(cmd, *args) - puts "#{cmd} #{args * " "}" if ARGV.verbose? + puts "#{cmd} #{args*" "}" if ARGV.verbose? _system(cmd, *args) end @@ -262,6 +262,14 @@ ensure ENV["PATH"] = old_path end +def with_homebrew_path + old_path = ENV["PATH"] + ENV["PATH"] = ENV["HOMEBREW_PATH"] + yield +ensure + ENV["PATH"] = old_path +end + def with_custom_locale(locale) old_locale = ENV["LC_ALL"] ENV["LC_ALL"] = locale @@ -321,23 +329,13 @@ end def which_editor editor = ENV.values_at("HOMEBREW_EDITOR", "HOMEBREW_VISUAL").compact.reject(&:empty?).first - if editor - editor_name, _, editor_args = editor.partition " " - editor_path = which(editor_name, ENV["HOMEBREW_PATH"]) - editor = if editor_args.to_s.empty? - editor_path.to_s - else - "#{editor_path} #{editor_args}" - end - return editor + return editor unless editor.nil? + + # Find Textmate, BBEdit / TextWrangler, or vim + %w[mate edit vim].each do |candidate| + editor = candidate if which(candidate, ENV["HOMEBREW_PATH"]) end - # Find Textmate - editor = which("mate", ENV["HOMEBREW_PATH"]) - # Find BBEdit/TextWrangler - editor ||= which("edit", ENV["HOMEBREW_PATH"]) - # Find vim - editor ||= which("vim", ENV["HOMEBREW_PATH"]) # Default to standard vim editor ||= "/usr/bin/vim" @@ -347,12 +345,12 @@ def which_editor or HOMEBREW_EDITOR to your preferred text editor. EOS - editor.to_s + editor end def exec_editor(*args) puts "Editing #{args.join "\n"}" - safe_exec(which_editor, *args) + with_homebrew_path { safe_exec(which_editor, *args) } end def exec_browser(*args) |
