aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Library/.rubocop_todo.yml35
-rw-r--r--Library/Homebrew/brew.rb6
-rw-r--r--Library/Homebrew/build.rb5
-rw-r--r--Library/Homebrew/caveats.rb51
-rw-r--r--Library/Homebrew/cleaner.rb6
-rw-r--r--Library/Homebrew/cmd/cleanup.rb14
-rw-r--r--Library/Homebrew/cmd/diy.rb8
-rw-r--r--Library/Homebrew/cmd/info.rb7
-rw-r--r--Library/Homebrew/cmd/install.rb10
-rw-r--r--Library/Homebrew/cmd/reinstall.rb9
-rw-r--r--Library/Homebrew/cmd/search.rb7
-rw-r--r--Library/Homebrew/dev-cmd/audit.rb103
-rw-r--r--Library/Homebrew/dev-cmd/bottle.rb64
13 files changed, 150 insertions, 175 deletions
diff --git a/Library/.rubocop_todo.yml b/Library/.rubocop_todo.yml
index e27d89617..c6e126a9e 100644
--- a/Library/.rubocop_todo.yml
+++ b/Library/.rubocop_todo.yml
@@ -1,6 +1,6 @@
# This configuration was generated by
# `rubocop --auto-gen-config --exclude-limit 100`
-# on 2016-09-21 14:04:48 +0200 using RuboCop version 0.43.0.
+# on 2016-09-22 20:07:41 +0200 using RuboCop version 0.43.0.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
@@ -74,7 +74,7 @@ Metrics/BlockNesting:
# Offense count: 20
# Configuration parameters: CountComments.
Metrics/ModuleLength:
- Max: 373
+ Max: 370
# Offense count: 2
# Configuration parameters: CountKeywordArgs.
@@ -119,13 +119,6 @@ Style/ConstantName:
Exclude:
- 'Homebrew/os/mac.rb'
-# Offense count: 3
-Style/DoubleNegation:
- Exclude:
- - 'Homebrew/os/mac/cctools_keg.rb'
- - 'Homebrew/os/mac/ruby_keg.rb'
- - 'Homebrew/os/mac/xcode.rb'
-
# Offense count: 1
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: format, sprintf, percent
@@ -140,25 +133,14 @@ Style/GlobalVars:
- 'Homebrew/diagnostic.rb'
- 'Homebrew/utils.rb'
-# Offense count: 97
+# Offense count: 70
# Configuration parameters: MinBodyLength.
Style/GuardClause:
Exclude:
- 'Taps/**/*'
- - 'Homebrew/brew.rb'
- - 'Homebrew/build.rb'
- - 'Homebrew/caveats.rb'
- - 'Homebrew/cleaner.rb'
- - 'Homebrew/cmd/cleanup.rb'
- - 'Homebrew/cmd/diy.rb'
- - 'Homebrew/cmd/info.rb'
- - 'Homebrew/cmd/install.rb'
- - 'Homebrew/cmd/reinstall.rb'
- - 'Homebrew/cmd/search.rb'
- 'Homebrew/cmd/update-report.rb'
- 'Homebrew/dependency_collector.rb'
- 'Homebrew/dev-cmd/audit.rb'
- - 'Homebrew/dev-cmd/bottle.rb'
- 'Homebrew/dev-cmd/pull.rb'
- 'Homebrew/dev-cmd/test-bot.rb'
- 'Homebrew/download_strategy.rb'
@@ -188,7 +170,7 @@ Style/GuardClause:
- 'Homebrew/utils/popen.rb'
- 'Homebrew/version.rb'
-# Offense count: 52
+# Offense count: 51
# Cop supports --auto-correct.
# Configuration parameters: MaxLineLength.
Style/IfUnlessModifier:
@@ -221,7 +203,6 @@ Style/IfUnlessModifier:
- 'Homebrew/formulary.rb'
- 'Homebrew/language/haskell.rb'
- 'Homebrew/migrator.rb'
- - 'Homebrew/os/mac/cctools_mach.rb'
- 'Homebrew/tab.rb'
- 'Homebrew/utils/git.rb'
@@ -277,11 +258,3 @@ Style/OpMethod:
# SupportedStyles: use_perl_names, use_english_names
Style/SpecialGlobalVars:
EnforcedStyle: use_perl_names
-
-# Offense count: 1
-# Cop supports --auto-correct.
-# Configuration parameters: EnforcedStyle, SupportedStyles, AllowSafeAssignment.
-# SupportedStyles: require_parentheses, require_no_parentheses
-Style/TernaryParentheses:
- Exclude:
- - 'Homebrew/formula.rb'
diff --git a/Library/Homebrew/brew.rb b/Library/Homebrew/brew.rb
index 0d1bcbdda..1ba3fb8c2 100644
--- a/Library/Homebrew/brew.rb
+++ b/Library/Homebrew/brew.rb
@@ -37,9 +37,9 @@ begin
cmd = nil
ARGV.dup.each_with_index do |arg, i|
- if help_flag && cmd
- break
- elsif help_flag_list.include?(arg)
+ break if help_flag && cmd
+
+ if help_flag_list.include?(arg)
# Option-style help: Both `--help <cmd>` and `<cmd> --help` are fine.
help_flag = true
elsif arg == "help" && !cmd
diff --git a/Library/Homebrew/build.rb b/Library/Homebrew/build.rb
index f4dde895a..d3c2833d4 100644
--- a/Library/Homebrew/build.rb
+++ b/Library/Homebrew/build.rb
@@ -31,9 +31,8 @@ class Build
def post_superenv_hacks
# Only allow Homebrew-approved directories into the PATH, unless
# a formula opts-in to allowing the user's path.
- if formula.env.userpaths? || reqs.any? { |rq| rq.env.userpaths? }
- ENV.userpaths!
- end
+ return unless formula.env.userpaths? || reqs.any? { |rq| rq.env.userpaths? }
+ ENV.userpaths!
end
def effective_build_options_for(dependent)
diff --git a/Library/Homebrew/caveats.rb b/Library/Homebrew/caveats.rb
index 9c1787f87..a5568cb29 100644
--- a/Library/Homebrew/caveats.rb
+++ b/Library/Homebrew/caveats.rb
@@ -69,27 +69,34 @@ class Caveats
end
def bash_completion_caveats
- if keg && keg.completion_installed?(:bash) then <<-EOS.undent
+ return unless keg
+ return unless keg.completion_installed?(:bash)
+
+ <<-EOS.undent
Bash completion has been installed to:
#{HOMEBREW_PREFIX}/etc/bash_completion.d
- EOS
- end
+ EOS
end
def zsh_completion_caveats
- if keg && keg.completion_installed?(:zsh) then <<-EOS.undent
+ return unless keg
+ return unless keg.completion_installed?(:zsh)
+
+ <<-EOS.undent
zsh completion has been installed to:
#{HOMEBREW_PREFIX}/share/zsh/site-functions
- EOS
- end
+ EOS
end
def fish_completion_caveats
- if keg && keg.completion_installed?(:fish) && which("fish") then <<-EOS.undent
+ return unless keg
+ return unless keg.completion_installed?(:fish)
+ return unless which("fish")
+
+ <<-EOS.undent
fish completion has been installed to:
#{HOMEBREW_PREFIX}/share/fish/vendor_completions.d
- EOS
- end
+ EOS
end
def python_caveats
@@ -140,22 +147,24 @@ class Caveats
end
def app_caveats
- if keg && keg.app_installed?
- <<-EOS.undent
- .app bundles were installed.
- Run `brew linkapps #{keg.name}` to symlink these to /Applications.
- EOS
- end
+ return unless keg
+ return unless keg.app_installed?
+
+ <<-EOS.undent
+ .app bundles were installed.
+ Run `brew linkapps #{keg.name}` to symlink these to /Applications.
+ EOS
end
def elisp_caveats
return if f.keg_only?
- if keg && keg.elisp_installed?
- <<-EOS.undent
- Emacs Lisp files have been installed to:
- #{HOMEBREW_PREFIX}/share/emacs/site-lisp/#{f.name}
- EOS
- end
+ return unless keg
+ return unless keg.elisp_installed?
+
+ <<-EOS.undent
+ Emacs Lisp files have been installed to:
+ #{HOMEBREW_PREFIX}/share/emacs/site-lisp/#{f.name}
+ EOS
end
def plist_caveats
diff --git a/Library/Homebrew/cleaner.rb b/Library/Homebrew/cleaner.rb
index d8a998576..7456e18d6 100644
--- a/Library/Homebrew/cleaner.rb
+++ b/Library/Homebrew/cleaner.rb
@@ -87,9 +87,9 @@ class Cleaner
Find.prune if @f.skip_clean? path
- if path.symlink? || path.directory?
- next
- elsif path.extname == ".la"
+ next if path.symlink? || path.directory?
+
+ if path.extname == ".la"
path.unlink
elsif path.basename.to_s == "perllocal.pod"
# Both this file & the .packlist one below are completely unnecessary
diff --git a/Library/Homebrew/cmd/cleanup.rb b/Library/Homebrew/cmd/cleanup.rb
index a9d3fbcde..6e0915c9a 100644
--- a/Library/Homebrew/cmd/cleanup.rb
+++ b/Library/Homebrew/cmd/cleanup.rb
@@ -22,13 +22,13 @@ module Homebrew
ARGV.resolved_formulae.each { |f| Cleanup.cleanup_formula f }
end
- if Cleanup.disk_cleanup_size > 0
- disk_space = disk_usage_readable(Cleanup.disk_cleanup_size)
- if ARGV.dry_run?
- ohai "This operation would free approximately #{disk_space} of disk space."
- else
- ohai "This operation has freed approximately #{disk_space} of disk space."
- end
+ return if Cleanup.disk_cleanup_size.zero?
+
+ disk_space = disk_usage_readable(Cleanup.disk_cleanup_size)
+ if ARGV.dry_run?
+ ohai "This operation would free approximately #{disk_space} of disk space."
+ else
+ ohai "This operation has freed approximately #{disk_space} of disk space."
end
end
end
diff --git a/Library/Homebrew/cmd/diy.rb b/Library/Homebrew/cmd/diy.rb
index 8262352f8..95ec7fe35 100644
--- a/Library/Homebrew/cmd/diy.rb
+++ b/Library/Homebrew/cmd/diy.rb
@@ -31,11 +31,9 @@ module Homebrew
def detect_version(path)
version = path.version.to_s
- if version.empty?
- raise "Couldn't determine version, set it with --version=<version>"
- else
- version
- end
+ raise "Couldn't determine version, set it with --version=<version>" if version.empty?
+
+ version
end
def detect_name(path, version)
diff --git a/Library/Homebrew/cmd/info.rb b/Library/Homebrew/cmd/info.rb
index 2474aad57..09c832203 100644
--- a/Library/Homebrew/cmd/info.rb
+++ b/Library/Homebrew/cmd/info.rb
@@ -54,11 +54,8 @@ module Homebrew
end
rescue FormulaUnavailableError
# No formula with this name, try a blacklist lookup
- if (blacklist = blacklisted?(f))
- puts blacklist
- else
- raise
- end
+ raise unless (blacklist = blacklisted?(f))
+ puts blacklist
end
end
end
diff --git a/Library/Homebrew/cmd/install.rb b/Library/Homebrew/cmd/install.rb
index 50439ccf9..0a6dd5a46 100644
--- a/Library/Homebrew/cmd/install.rb
+++ b/Library/Homebrew/cmd/install.rb
@@ -245,11 +245,11 @@ module Homebrew
end
def check_macports
- unless MacOS.macports_or_fink.empty?
- opoo "It appears you have MacPorts or Fink installed."
- puts "Software installed with other package managers causes known problems for"
- puts "Homebrew. If a formula fails to build, uninstall MacPorts/Fink and try again."
- end
+ return if MacOS.macports_or_fink.empty?
+
+ opoo "It appears you have MacPorts or Fink installed."
+ puts "Software installed with other package managers causes known problems for"
+ puts "Homebrew. If a formula fails to build, uninstall MacPorts/Fink and try again."
end
def check_cellar
diff --git a/Library/Homebrew/cmd/reinstall.rb b/Library/Homebrew/cmd/reinstall.rb
index e51aace2a..bda6022bf 100644
--- a/Library/Homebrew/cmd/reinstall.rb
+++ b/Library/Homebrew/cmd/reinstall.rb
@@ -58,10 +58,11 @@ module Homebrew
def restore_backup(keg, formula)
path = backup_path(keg)
- if path.directory?
- path.rename keg
- keg.link unless formula.keg_only?
- end
+
+ return unless path.directory?
+
+ path.rename keg
+ keg.link unless formula.keg_only?
end
def backup_path(path)
diff --git a/Library/Homebrew/cmd/search.rb b/Library/Homebrew/cmd/search.rb
index 3f00e8a10..aa80ec589 100644
--- a/Library/Homebrew/cmd/search.rb
+++ b/Library/Homebrew/cmd/search.rb
@@ -171,10 +171,11 @@ module Homebrew
rescue
canonical_name = canonical_full_name = name
end
+
# Ignore aliases from results when the full name was also found
- if aliases.include?(name) && results.include?(canonical_full_name)
- next
- elsif (HOMEBREW_CELLAR/canonical_name).directory?
+ next if aliases.include?(name) && results.include?(canonical_full_name)
+
+ if (HOMEBREW_CELLAR/canonical_name).directory?
pretty_installed(name)
else
name
diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb
index 55f545d0c..61d136daf 100644
--- a/Library/Homebrew/dev-cmd/audit.rb
+++ b/Library/Homebrew/dev-cmd/audit.rb
@@ -83,11 +83,11 @@ module Homebrew
end
end
- unless problem_count.zero?
- problems = "problem" + plural(problem_count)
- formulae = "formula" + plural(formula_count, "e")
- ofail "#{problem_count} #{problems} in #{formula_count} #{formulae}"
- end
+ return if problem_count.zero?
+
+ problems = "problem" + plural(problem_count)
+ formulae = "formula" + plural(formula_count, "e")
+ ofail "#{problem_count} #{problems} in #{formula_count} #{formulae}"
end
end
@@ -279,9 +279,11 @@ class FormulaAuditor
end
end
end
+
if present.include?("head") && present.include?("head block")
problem "Should not have both `head` and `head do`"
end
+
if present.include?("bottle modifier") && present.include?("bottle block")
problem "Should not have `bottle :unneeded/:disable` and `bottle do`"
end
@@ -668,24 +670,26 @@ class FormulaAuditor
end
revision_map = attributes_map[:revision]
- if formula.revision.nonzero?
- if formula.stable
- if revision_map[formula.stable.version].empty? # check stable spec
- problem "'revision #{formula.revision}' should be removed"
- end
- else # head/devel-only formula
+
+ return if formula.revision.zero?
+
+ if formula.stable
+ if revision_map[formula.stable.version].empty? # check stable spec
problem "'revision #{formula.revision}' should be removed"
end
+ else # head/devel-only formula
+ problem "'revision #{formula.revision}' should be removed"
end
end
def audit_legacy_patches
return unless formula.respond_to?(:patches)
legacy_patches = Patch.normalize_legacy_patches(formula.patches).grep(LegacyPatch)
- unless legacy_patches.empty?
- problem "Use the patch DSL instead of defining a 'patches' method"
- legacy_patches.each { |p| audit_patch(p) }
- end
+
+ return if legacy_patches.empty?
+
+ problem "Use the patch DSL instead of defining a 'patches' method"
+ legacy_patches.each { |p| audit_patch(p) }
end
def audit_patch(patch)
@@ -961,61 +965,56 @@ class FormulaAuditor
problem "Use Language::Node for npm install args"
end
- if @strict
- if line =~ /system ((["'])[^"' ]*(?:\s[^"' ]*)+\2)/
- bad_system = $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
+ return unless @strict
- if line =~ /(require ["']formula["'])/
- problem "`#{$1}` is now unnecessary"
+ if line =~ /system ((["'])[^"' ]*(?:\s[^"' ]*)+\2)/
+ bad_system = $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
- if line =~ %r{#\{share\}/#{Regexp.escape(formula.name)}[/'"]}
- problem "Use \#{pkgshare} instead of \#{share}/#{formula.name}"
- end
+ if line =~ /(require ["']formula["'])/
+ problem "`#{$1}` is now unnecessary"
+ end
- if line =~ %r{share(\s*[/+]\s*)(['"])#{Regexp.escape(formula.name)}(?:\2|/)}
- problem "Use pkgshare instead of (share#{$1}\"#{formula.name}\")"
- end
+ if line =~ %r{#\{share\}/#{Regexp.escape(formula.name)}[/'"]}
+ problem "Use \#{pkgshare} instead of \#{share}/#{formula.name}"
+ end
+
+ if line =~ %r{share(\s*[/+]\s*)(['"])#{Regexp.escape(formula.name)}(?:\2|/)}
+ problem "Use pkgshare instead of (share#{$1}\"#{formula.name}\")"
end
end
def audit_caveats
- caveats = formula.caveats.to_s
-
- if caveats.include?("setuid")
- problem "Don't recommend setuid in the caveats, suggest sudo instead."
- end
+ 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
return unless formula.tap && formula.tap.official?
+ return unless formula.tap.tap_migrations.key?(formula.name)
- if formula.tap.tap_migrations.key?(formula.name)
- problem <<-EOS.undent
- #{formula.name} seems to be listed in tap_migrations.json!
- Please remove #{formula.name} from present tap & tap_migrations.json
- before submitting it to Homebrew/homebrew-#{formula.tap.repo}.
- EOS
- end
+ problem <<-EOS.undent
+ #{formula.name} seems to be listed in tap_migrations.json!
+ Please remove #{formula.name} from present tap & tap_migrations.json
+ before submitting it to Homebrew/homebrew-#{formula.tap.repo}.
+ EOS
end
def audit_prefix_has_contents
return unless formula.prefix.directory?
+ return unless Keg.new(formula.prefix).empty_installation?
- if Keg.new(formula.prefix).empty_installation?
- problem <<-EOS.undent
- The installation seems to be empty. Please ensure the prefix
- is set correctly and expected files are installed.
- The prefix configure/make argument may be case-sensitive.
- EOS
- end
+ problem <<-EOS.undent
+ The installation seems to be empty. Please ensure the prefix
+ is set correctly and expected files are installed.
+ The prefix configure/make argument may be case-sensitive.
+ EOS
end
def audit_conditional_dep(dep, condition, line)
@@ -1184,9 +1183,7 @@ class ResourceAuditor
end
end
- using_strategy = DownloadStrategyDetector.detect("", using)
-
- if url_strategy == using_strategy
+ if url_strategy == DownloadStrategyDetector.detect("", using)
problem "Redundant :using value in URL"
end
end
diff --git a/Library/Homebrew/dev-cmd/bottle.rb b/Library/Homebrew/dev-cmd/bottle.rb
index fe07526f3..797828e0e 100644
--- a/Library/Homebrew/dev-cmd/bottle.rb
+++ b/Library/Homebrew/dev-cmd/bottle.rb
@@ -51,10 +51,11 @@ module Homebrew
end
@put_filenames ||= []
- unless @put_filenames.include? filename
- puts "#{Tty.red}#{filename}#{Tty.reset}"
- @put_filenames << filename
- end
+
+ return if @put_filenames.include? filename
+
+ puts "#{Tty.red}#{filename}#{Tty.reset}"
+ @put_filenames << filename
end
result = false
@@ -137,11 +138,11 @@ module Homebrew
tap = f.tap
unless tap
- if ARGV.include?("--force-core-tap")
- tap = CoreTap.instance
- else
+ unless ARGV.include?("--force-core-tap")
return ofail "Formula not from core or any taps: #{f.full_name}"
end
+
+ tap = CoreTap.instance
end
if f.bottle_disabled?
@@ -323,34 +324,33 @@ module Homebrew
puts "./#{filename}"
puts output
- if ARGV.include? "--json"
- json = {
- f.full_name => {
- "formula" => {
- "pkg_version" => f.pkg_version.to_s,
- "path" => f.path.to_s.strip_prefix("#{HOMEBREW_REPOSITORY}/"),
- },
- "bottle" => {
- "root_url" => bottle.root_url,
- "prefix" => bottle.prefix,
- "cellar" => bottle.cellar.to_s,
- "rebuild" => bottle.rebuild,
- "tags" => {
- Utils::Bottles.tag.to_s => {
- "filename" => filename.to_s,
- "sha256" => sha256,
- },
+ return unless ARGV.include? "--json"
+ json = {
+ f.full_name => {
+ "formula" => {
+ "pkg_version" => f.pkg_version.to_s,
+ "path" => f.path.to_s.strip_prefix("#{HOMEBREW_REPOSITORY}/"),
+ },
+ "bottle" => {
+ "root_url" => bottle.root_url,
+ "prefix" => bottle.prefix,
+ "cellar" => bottle.cellar.to_s,
+ "rebuild" => bottle.rebuild,
+ "tags" => {
+ Utils::Bottles.tag.to_s => {
+ "filename" => filename.to_s,
+ "sha256" => sha256,
},
},
- "bintray" => {
- "package" => Utils::Bottles::Bintray.package(f.name),
- "repository" => Utils::Bottles::Bintray.repository(tap),
- },
},
- }
- File.open("#{filename.prefix}.bottle.json", "w") do |file|
- file.write Utils::JSON.dump json
- end
+ "bintray" => {
+ "package" => Utils::Bottles::Bintray.package(f.name),
+ "repository" => Utils::Bottles::Bintray.repository(tap),
+ },
+ },
+ }
+ File.open("#{filename.prefix}.bottle.json", "w") do |file|
+ file.write Utils::JSON.dump json
end
end