Fix brew style

This commit is contained in:
Bo Anderson 2021-03-26 14:11:03 +00:00
parent 7f272b7875
commit 450bc4ab33
No known key found for this signature in database
GPG Key ID: 3DB94E204E137D65
8 changed files with 27 additions and 42 deletions

View File

@ -20,10 +20,8 @@ class CaskDependent
end end
def deps def deps
@deps ||= begin @deps ||= @cask.depends_on.formula.map do |f|
@cask.depends_on.formula.map do |f| Dependency.new f
Dependency.new f
end
end end
end end

View File

@ -430,11 +430,9 @@ module Homebrew
end end
def rm_ds_store(dirs = nil) def rm_ds_store(dirs = nil)
dirs ||= begin dirs ||= Keg::MUST_EXIST_DIRECTORIES + [
Keg::MUST_EXIST_DIRECTORIES + [ HOMEBREW_PREFIX/"Caskroom",
HOMEBREW_PREFIX/"Caskroom", ]
]
end
dirs.select(&:directory?) dirs.select(&:directory?)
.flat_map { |d| Pathname.glob("#{d}/**/.DS_Store") } .flat_map { |d| Pathname.glob("#{d}/**/.DS_Store") }
.each(&:unlink) .each(&:unlink)

View File

@ -41,24 +41,21 @@ class DevelopmentTools
end end
def clang_version def clang_version
@clang_version ||= begin @clang_version ||= if (path = locate("clang")) &&
if (path = locate("clang")) && (build_version = `#{path} --version`[/(?:clang|LLVM) version (\d+\.\d)/, 1])
(build_version = `#{path} --version`[/(?:clang|LLVM) version (\d+\.\d)/, 1]) Version.new build_version
Version.new build_version else
else Version::NULL
Version::NULL
end
end end
end end
def clang_build_version def clang_build_version
@clang_build_version ||= begin @clang_build_version ||= if (path = locate("clang")) &&
if (path = locate("clang")) && (build_version = `#{path} --version`[
(build_version = `#{path} --version`[%r{clang(-| version [^ ]+ \(tags/RELEASE_)(\d{2,})}, 2]) %r{clang(-| version [^ ]+ \(tags/RELEASE_)(\d{2,})}, 2])
Version.new build_version Version.new build_version
else else
Version::NULL Version::NULL
end
end end
end end

View File

@ -13,9 +13,7 @@ module MachOShim
delegate [:dylib_id, :rpaths, :delete_rpath] => :macho delegate [:dylib_id, :rpaths, :delete_rpath] => :macho
def macho def macho
@macho ||= begin @macho ||= MachO.open(to_s)
MachO.open(to_s)
end
end end
private :macho private :macho

View File

@ -170,12 +170,10 @@ module OS
# This will only look up SDKs on Xcode 10 or newer, and still # This will only look up SDKs on Xcode 10 or newer, and still
# return nil SDKs for Xcode 9 and older. # return nil SDKs for Xcode 9 and older.
def sdk_prefix def sdk_prefix
@sdk_prefix ||= begin @sdk_prefix ||= if CLT.provides_sdk?
if CLT.provides_sdk? "#{CLT::PKG_PATH}/SDKs"
"#{CLT::PKG_PATH}/SDKs" else
else ""
""
end
end end
end end
end end

View File

@ -33,12 +33,10 @@ module RuboCop
end end
def cask_token def cask_token
@cask_token ||= begin @cask_token ||= if dsl_version?
if dsl_version? pair_node.val_node.children.first
pair_node.val_node.children.first else
else method_node.first_argument.str_content
method_node.first_argument.str_content
end
end end
end end

View File

@ -59,7 +59,7 @@ module RuboCop
end end
# Check if the desc starts with the formula's or cask's name. # Check if the desc starts with the formula's or cask's name.
name_regex = name.delete("-").split("").join('[\s\-]?') name_regex = name.delete("-").chars.join('[\s\-]?')
if regex_match_group(desc, /^#{name_regex}\b/i) if regex_match_group(desc, /^#{name_regex}\b/i)
desc_problem "Description shouldn't start with the #{type} name." desc_problem "Description shouldn't start with the #{type} name."
end end

View File

@ -139,9 +139,7 @@ module GitHub
end end
def credentials def credentials
@credentials ||= begin @credentials ||= Homebrew::EnvConfig.github_api_token || keychain_username_password
Homebrew::EnvConfig.github_api_token || keychain_username_password
end
end end
sig { returns(Symbol) } sig { returns(Symbol) }