core file style update

This commit is contained in:
Xu Cheng 2015-08-22 13:15:33 +08:00
parent 3d1f9e0a9c
commit a88c40b8c8
12 changed files with 21 additions and 21 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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?

View File

@ -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}

View File

@ -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

View File

@ -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)

View File

@ -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)

View File

@ -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

View File

@ -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?

View File

@ -5,7 +5,7 @@ require "tab"
require "keg"
class Formula
def set_oldname oldname
def set_oldname(oldname)
@oldname = oldname
end
end

View File

@ -2,7 +2,6 @@ require "testing_env"
require "tempfile"
class UtilTests < Homebrew::TestCase
def setup
@dir = Pathname.new(mktmpdir)
end