From a88c40b8c888064f6514cf0646ea2140e2578d57 Mon Sep 17 00:00:00 2001 From: Xu Cheng Date: Sat, 22 Aug 2015 13:15:33 +0800 Subject: [PATCH] core file style update --- Library/Homebrew/cmd/audit.rb | 2 +- Library/Homebrew/cmd/cleanup.rb | 2 +- Library/Homebrew/cmd/doctor.rb | 2 +- Library/Homebrew/cmd/update.rb | 3 ++- Library/Homebrew/exceptions.rb | 8 ++++---- Library/Homebrew/extend/ARGV.rb | 10 +++++----- Library/Homebrew/formula_installer.rb | 2 +- Library/Homebrew/formulary.rb | 6 +++--- Library/Homebrew/keg_relocate.rb | 2 +- Library/Homebrew/test/test_formula_installer_bottle.rb | 2 +- Library/Homebrew/test/test_migrator.rb | 2 +- Library/Homebrew/test/test_utils.rb | 1 - 12 files changed, 21 insertions(+), 21 deletions(-) diff --git a/Library/Homebrew/cmd/audit.rb b/Library/Homebrew/cmd/audit.rb index 49396224b5..ca76c1c539 100644 --- a/Library/Homebrew/cmd/audit.rb +++ b/Library/Homebrew/cmd/audit.rb @@ -374,7 +374,7 @@ class FormulaAuditor problem "Description should use \"command-line\" instead of \"#{$1}\"" end - if desc =~ %r[^([Aa]n?)\s] + if desc =~ /^([Aa]n?)\s/ problem "Please remove the indefinite article \"#{$1}\" from the beginning of the description" end end diff --git a/Library/Homebrew/cmd/cleanup.rb b/Library/Homebrew/cmd/cleanup.rb index f9203c68dc..0561510cb9 100644 --- a/Library/Homebrew/cmd/cleanup.rb +++ b/Library/Homebrew/cmd/cleanup.rb @@ -133,7 +133,7 @@ module Homebrew workers.map(&:join) end - def prune?(path, options={}) + def prune?(path, options = {}) @time ||= Time.now path_modified_time = path.mtime diff --git a/Library/Homebrew/cmd/doctor.rb b/Library/Homebrew/cmd/doctor.rb index 97e31a8e24..910aedc52a 100644 --- a/Library/Homebrew/cmd/doctor.rb +++ b/Library/Homebrew/cmd/doctor.rb @@ -864,7 +864,7 @@ class Checks # https://help.github.com/articles/https-cloning-errors `git --version`.chomp =~ /git version ((?:\d+\.?)+)/ - if $1 && Version.new($1) < Version.new("1.7.10") then + if $1 && Version.new($1) < Version.new("1.7.10") git_upgrade_cmd = Formula["git"].any_version_installed? ? "upgrade" : "install" <<-EOS.undent diff --git a/Library/Homebrew/cmd/update.rb b/Library/Homebrew/cmd/update.rb index d9cecf5d54..33c7c49ae0 100644 --- a/Library/Homebrew/cmd/update.rb +++ b/Library/Homebrew/cmd/update.rb @@ -71,7 +71,8 @@ module Homebrew user, repo, oldname = oldname.split("/", 3) newname = newname.split("/", 3).last else - user, repo = "homebrew", "homebrew" + user = "homebrew" + repo = "homebrew" end next unless (dir = HOMEBREW_CELLAR/oldname).directory? && !dir.subdirs.empty? diff --git a/Library/Homebrew/exceptions.rb b/Library/Homebrew/exceptions.rb index 9e3a29983c..f38233a4f5 100644 --- a/Library/Homebrew/exceptions.rb +++ b/Library/Homebrew/exceptions.rb @@ -99,7 +99,7 @@ class TapFormulaWithOldnameAmbiguityError < RuntimeError end super <<-EOS.undent - Formulae with '#{name}' old name found in multiple taps: #{taps.map { |t| "\n * #{t}" }.join} + Formulae with '#{name}' old name found in multiple taps: #{taps.map { |t| "\n * #{t}" }.join} Please use the fully-qualified name e.g. #{taps.first}/#{name} to refer the formula or use its new name. EOS @@ -121,7 +121,7 @@ end class TapPinStatusError < RuntimeError attr_reader :name, :pinned - def initialize name, pinned + def initialize(name, pinned) @name = name @pinned = pinned @@ -297,7 +297,7 @@ class BuildToolsError < RuntimeError super <<-EOS.undent The following #{formula_text}: - #{formulae.join(', ')} + #{formulae.join(", ")} cannot be installed as a #{package_text} and must be built from source. #{xcode_text} EOS @@ -343,7 +343,7 @@ class BuildFlagsError < RuntimeError super <<-EOS.undent The following #{flag_text}: - #{flags.join(', ')} + #{flags.join(", ")} #{require_text} building tools, but none are installed. Either remove the #{flag_text} to attempt bottle installation, #{xcode_text} diff --git a/Library/Homebrew/extend/ARGV.rb b/Library/Homebrew/extend/ARGV.rb index 0f78769c5b..106aae7cf1 100644 --- a/Library/Homebrew/extend/ARGV.rb +++ b/Library/Homebrew/extend/ARGV.rb @@ -212,11 +212,11 @@ module HomebrewArgvExtension def collect_build_flags build_flags = [] - build_flags << '--HEAD' if build_head? - build_flags << '--universal' if build_universal? - build_flags << '--32-bit' if build_32_bit? - build_flags << '--build-bottle' if build_bottle? - build_flags << '--build-from-source' if build_from_source? + build_flags << "--HEAD" if build_head? + build_flags << "--universal" if build_universal? + build_flags << "--32-bit" if build_32_bit? + build_flags << "--build-bottle" if build_bottle? + build_flags << "--build-from-source" if build_from_source? build_flags end diff --git a/Library/Homebrew/formula_installer.rb b/Library/Homebrew/formula_installer.rb index 8c15367a9e..e47840a1fa 100644 --- a/Library/Homebrew/formula_installer.rb +++ b/Library/Homebrew/formula_installer.rb @@ -160,7 +160,7 @@ class FormulaInstaller raise BuildToolsError.new([formula]) end - if !ignore_deps? + unless ignore_deps? deps = compute_dependencies check_dependencies_bottled(deps) if pour_bottle? install_dependencies(deps) diff --git a/Library/Homebrew/formulary.rb b/Library/Homebrew/formulary.rb index 755d9f87c8..3198ebad20 100644 --- a/Library/Homebrew/formulary.rb +++ b/Library/Homebrew/formulary.rb @@ -249,7 +249,7 @@ class Formulary return AliasLoader.new(possible_alias) end - possible_tap_formulae = tap_paths(ref) + possible_tap_formulae = tap_paths(ref) if possible_tap_formulae.size > 1 raise TapFormulaAmbiguityError.new(ref, possible_tap_formulae) elsif possible_tap_formulae.size == 1 @@ -288,7 +288,7 @@ class Formulary Pathname.new("#{HOMEBREW_LIBRARY}/Formula/#{name.downcase}.rb") end - def self.tap_paths(name, taps=Dir["#{HOMEBREW_LIBRARY}/Taps/*/*/"]) + def self.tap_paths(name, taps = Dir["#{HOMEBREW_LIBRARY}/Taps/*/*/"]) name = name.downcase taps.map do |tap| Pathname.glob([ @@ -299,7 +299,7 @@ class Formulary end.compact end - def self.find_with_priority(ref, spec=:stable) + def self.find_with_priority(ref, spec = :stable) possible_pinned_tap_formulae = tap_paths(ref, Dir["#{HOMEBREW_LIBRARY}/PinnedTaps/*/*/"]).map(&:realpath) if possible_pinned_tap_formulae.size > 1 raise TapFormulaAmbiguityError.new(ref, possible_pinned_tap_formulae) diff --git a/Library/Homebrew/keg_relocate.rb b/Library/Homebrew/keg_relocate.rb index 05d19db4d6..f0d6abefed 100644 --- a/Library/Homebrew/keg_relocate.rb +++ b/Library/Homebrew/keg_relocate.rb @@ -99,7 +99,7 @@ class Keg def install_name_tool(*args) tool = MacOS.install_name_tool - system(tool, *args) or raise ErrorDuringExecution.new(tool, args) + system(tool, *args) || raise(ErrorDuringExecution.new(tool, args)) end # If file is a dylib or bundle itself, look for the dylib named by diff --git a/Library/Homebrew/test/test_formula_installer_bottle.rb b/Library/Homebrew/test/test_formula_installer_bottle.rb index 4d2d1676f8..61ed78b192 100644 --- a/Library/Homebrew/test/test_formula_installer_bottle.rb +++ b/Library/Homebrew/test/test_formula_installer_bottle.rb @@ -70,7 +70,7 @@ class InstallBottleTests < Homebrew::TestCase installer = FormulaInstaller.new(formula) assert_raises(BuildToolsError) do - installer.install + installer.install end refute_predicate formula, :installed? diff --git a/Library/Homebrew/test/test_migrator.rb b/Library/Homebrew/test/test_migrator.rb index 236c7e00d2..e85483a954 100644 --- a/Library/Homebrew/test/test_migrator.rb +++ b/Library/Homebrew/test/test_migrator.rb @@ -5,7 +5,7 @@ require "tab" require "keg" class Formula - def set_oldname oldname + def set_oldname(oldname) @oldname = oldname end end diff --git a/Library/Homebrew/test/test_utils.rb b/Library/Homebrew/test/test_utils.rb index 9dc2830845..915e17e709 100644 --- a/Library/Homebrew/test/test_utils.rb +++ b/Library/Homebrew/test/test_utils.rb @@ -2,7 +2,6 @@ require "testing_env" require "tempfile" class UtilTests < Homebrew::TestCase - def setup @dir = Pathname.new(mktmpdir) end