more core file style updated by rubocop

This commit is contained in:
Xu Cheng 2015-08-06 15:45:52 +08:00
parent 3f8ce5f1a9
commit b121e5fd7b
18 changed files with 24 additions and 23 deletions

View File

@ -21,7 +21,7 @@ class Cmd
end
def mode
if @arg0 == "cpp" or @arg0 == "ld"
if @arg0 == "cpp" || @arg0 == "ld"
@arg0.to_sym
elsif @args.include? "-c"
if @arg0 =~ /(?:c|g|clang)\+\+/
@ -61,7 +61,7 @@ class Cmd
end
def args
if @args.length == 1 and @args[0] == "-v"
if @args.length == 1 && @args[0] == "-v"
# Don't add linker arguments if -v passed as sole option. This stops gcc
# -v with no other arguments from outputting a linker error. Some
# software uses gcc -v (wrongly) to sniff the GCC version.

View File

@ -17,7 +17,7 @@ when "git" then %W[HOMEBREW_GIT GIT]
when "svn" then %W[HOMEBREW_SVN]
else []
end.each do |key|
exec ENV[key], *ARGV if ENV[key] and File.executable? ENV[key]
exec ENV[key], *ARGV if ENV[key] && File.executable?(ENV[key])
end
brew_version = File.expand_path("#{D}/../../../bin/#{F}")

View File

@ -63,12 +63,12 @@ end
class Bintray
def self.package(formula_name)
formula_name.to_s.gsub "+", "x"
formula_name.to_s.tr("+", "x")
end
def self.repository(tap = nil)
return "bottles" if tap.nil? || tap == "Homebrew/homebrew"
"bottles-#{tap.sub(/^homebrew\/(homebrew-)?/i, "")}"
"bottles-#{tap.sub(%r{^homebrew/(homebrew-)?}i, "")}"
end
end

View File

@ -149,8 +149,11 @@ class Caveats
def plist_caveats
s = []
if f.plist || (keg && keg.plist_installed?)
destination = f.plist_startup ? "/Library/LaunchDaemons" \
: "~/Library/LaunchAgents"
destination = if f.plist_startup
"/Library/LaunchDaemons"
else
"~/Library/LaunchAgents"
end
plist_filename = if f.plist
f.plist_path.basename

View File

@ -16,7 +16,7 @@ module Homebrew
fields = line.split('"')
lang = fields[1]
path = fields[3]
lang.gsub!("-", "_")
lang.tr!("-", "_")
languages[lang] = path
end
end

View File

@ -360,7 +360,7 @@ class FormulaAuditor
EOS
end
if desc =~ %r[([Cc]ommand ?line)]
if desc =~ /([Cc]ommand ?line)/
problem "Description should use \"command-line\" instead of \"#{$1}\""
end
end

View File

@ -136,7 +136,7 @@ class PrettyListing
root.children.sort.each do |pn|
if pn.directory?
dirs << pn
elsif block_given? and yield pn
elsif block_given? && yield(pn)
puts pn
other = "other "
else

View File

@ -793,7 +793,7 @@ module Homebrew
bottle_args << "--tap=#{tap}" if tap
safe_system "brew", "bottle", *bottle_args
remote_repo = tap ? tap.gsub("/", "-") : "homebrew"
remote_repo = tap ? tap.tr("/", "-") : "homebrew"
remote = "git@github.com:BrewTestBot/#{remote_repo}.git"
tag = pr ? "pr-#{pr}" : "testing-#{number}"

View File

@ -5,7 +5,7 @@ def cache
# we do this for historic reasons, however the cache *should* be the same
# directory whichever user is used and whatever instance of brew is executed
home_cache = Pathname.new("~/Library/Caches/Homebrew").expand_path
if home_cache.directory? and home_cache.writable_real?
if home_cache.directory? && home_cache.writable_real?
home_cache
else
Pathname.new("/Library/Caches/Homebrew").extend Module.new {

View File

@ -53,7 +53,7 @@ module Debrew
menu.entries.each_with_index { |e, i| puts "#{i+1}. #{e.name}" }
print menu.prompt unless menu.prompt.nil?
input = $stdin.gets or exit
input = $stdin.gets || exit
input.chomp!
i = input.to_i

View File

@ -121,7 +121,7 @@ module Superenv
when "gcc-4.2"
begin
apple_gcc42 = Formulary.factory("apple-gcc42")
rescue FormulaUnavailableError
rescue FormulaUnavailableError
end
paths << apple_gcc42.opt_bin.to_s if apple_gcc42
when GNU_GCC_REGEXP

View File

@ -152,7 +152,7 @@ module FormulaCellarChecks
object files were linked against system openssl
These object files were linked against the deprecated system OpenSSL.
Adding `depends_on "openssl"` to the formula may help.
#{system_openssl * "\n "}
#{system_openssl * "\n "}
EOS
end

View File

@ -43,7 +43,7 @@ class Formulary
def self.class_s(name)
class_name = name.capitalize
class_name.gsub!(/[-_.\s]([a-zA-Z0-9])/) { $1.upcase }
class_name.gsub!("+", "x")
class_name.tr!("+", "x")
class_name
end

View File

@ -62,7 +62,7 @@ module MacCPUs
when 100
# This is the only 64-bit PPC CPU type, so it's useful
# to distinguish in `brew config` output and in bottle tags
MacOS.prefer_64_bit? ? :g5_64 : :g5 # PowerPC 970
MacOS.prefer_64_bit? ? :g5_64 : :g5 # PowerPC 970
else
:dunno
end

View File

@ -57,7 +57,7 @@ class Resource
# to be used as resource names without confusing software that
# interacts with download_name, e.g. github.com/foo/bar
def escaped_name
name.gsub("/", "-")
name.tr("/", "-")
end
def download_name

View File

@ -79,7 +79,6 @@ class Sandbox
end
def exec(*args)
seatbelt = Tempfile.new(["homebrew", ".sb"], HOMEBREW_TEMP)
seatbelt.write(@profile.dump)
seatbelt.close
@ -105,7 +104,6 @@ class Sandbox
]
quiet_system "syslog #{syslog_args * " "} | grep deny > #{@log}"
end
end
private

View File

@ -85,7 +85,7 @@ class InreplaceTest < Homebrew::TestCase
s.sub!("f", "b")
assert_equal "boo", s
s.gsub!("o", "e")
s.tr!("o", "e")
assert_equal "bee", s
end
@ -99,7 +99,7 @@ class InreplaceTest < Homebrew::TestCase
end
assert_raises(Utils::InreplaceError) do
inreplace("test") { |s| s.gsub! "d", "f" }
inreplace("test") { |s| s.tr!("d", "f") }
end
assert_raises(Utils::InreplaceError) do

View File

@ -299,7 +299,7 @@ class Version
# e.g. boost_1_39_0
m = /((?:\d+_)+\d+)$/.match(stem)
return m.captures.first.gsub("_", ".") unless m.nil?
return m.captures.first.tr("_", ".") unless m.nil?
# e.g. foobar-4.5.1-1
# e.g. unrtf_0.20.4-1