mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
Fix RuboCop checks.
This commit is contained in:
parent
33e5e157c4
commit
3a91c37e66
@ -212,6 +212,10 @@ Style/GuardClause:
|
||||
Style/HashSyntax:
|
||||
EnforcedStyle: ruby19
|
||||
|
||||
# so many of these in formulae and can't be autocorrected
|
||||
Style/StringConcatenation:
|
||||
Enabled: false
|
||||
|
||||
# ruby style guide favorite
|
||||
Style/StringLiterals:
|
||||
EnforcedStyle: double_quotes
|
||||
|
@ -63,7 +63,7 @@ Metrics/ModuleLength:
|
||||
Max: 600
|
||||
Metrics/PerceivedComplexity:
|
||||
Enabled: true
|
||||
Max: 80
|
||||
Max: 90
|
||||
|
||||
# we won't change backward compatible predicate names
|
||||
Naming/PredicateName:
|
||||
@ -139,3 +139,7 @@ Style/FrozenStringLiteralComment:
|
||||
# so many of these in formulae but none in here
|
||||
Style/GuardClause:
|
||||
Enabled: true
|
||||
|
||||
# so many of these in formulae but none in here
|
||||
Style/StringConcatenation:
|
||||
Enabled: true
|
||||
|
@ -98,11 +98,11 @@ module Cask
|
||||
@caskroom_path ||= Caskroom.path.join(token)
|
||||
end
|
||||
|
||||
def outdated?(greedy = false)
|
||||
!outdated_versions(greedy).empty?
|
||||
def outdated?(greedy: false)
|
||||
!outdated_versions(greedy: greedy).empty?
|
||||
end
|
||||
|
||||
def outdated_versions(greedy = false)
|
||||
def outdated_versions(greedy: false)
|
||||
# special case: tap version is not available
|
||||
return [] if version.nil?
|
||||
|
||||
@ -125,7 +125,7 @@ module Cask
|
||||
def outdated_info(greedy, verbose, json)
|
||||
return token if !verbose && !json
|
||||
|
||||
installed_versions = outdated_versions(greedy).join(", ")
|
||||
installed_versions = outdated_versions(greedy: greedy).join(", ")
|
||||
|
||||
if json
|
||||
{
|
||||
|
@ -44,7 +44,7 @@ module Cask
|
||||
|
||||
attr_reader :token, :path
|
||||
|
||||
def initialize(path)
|
||||
def initialize(path) # rubocop:disable Lint/MissingSuper
|
||||
path = Pathname(path).expand_path
|
||||
|
||||
@token = path.basename(".rb").to_s
|
||||
@ -79,7 +79,7 @@ module Cask
|
||||
class FromURILoader < FromPathLoader
|
||||
def self.can_load?(ref)
|
||||
uri_regex = ::URI::DEFAULT_PARSER.make_regexp
|
||||
return false unless ref.to_s.match?(Regexp.new('\A' + uri_regex.source + '\Z', uri_regex.options))
|
||||
return false unless ref.to_s.match?(Regexp.new("\\A#{uri_regex.source}\\Z", uri_regex.options))
|
||||
|
||||
uri = URI(ref)
|
||||
return false unless uri
|
||||
|
@ -58,20 +58,22 @@ module Cask
|
||||
}.freeze
|
||||
|
||||
def self.description
|
||||
max_command_len = Cmd.commands.map(&:length).max
|
||||
max_command_length = Cmd.commands.map(&:length).max
|
||||
|
||||
<<~EOS +
|
||||
command_lines = Cmd.command_classes
|
||||
.select(&:visible?)
|
||||
.map do |klass|
|
||||
" - #{"`#{klass.command_name}`".ljust(max_command_length + 2)} #{klass.short_description}\n"
|
||||
end
|
||||
|
||||
<<~EOS
|
||||
Homebrew Cask provides a friendly CLI workflow for the administration of macOS applications distributed as binaries.
|
||||
|
||||
Commands:
|
||||
#{command_lines.join}
|
||||
|
||||
See also: `man brew`
|
||||
EOS
|
||||
Cmd.command_classes
|
||||
.select(&:visible?)
|
||||
.map do |klass|
|
||||
" - #{"`#{klass.command_name}`".ljust(max_command_len + 2)} #{klass.short_description}\n"
|
||||
end
|
||||
.join +
|
||||
"\nSee also: `man brew`"
|
||||
end
|
||||
|
||||
def self.parser(&block)
|
||||
|
@ -17,7 +17,7 @@ module Cask
|
||||
def run
|
||||
success = true
|
||||
|
||||
checks = Homebrew::Diagnostic::Checks.new true
|
||||
checks = Homebrew::Diagnostic::Checks.new(verbose: true)
|
||||
checks.cask_checks.each do |check|
|
||||
out = checks.send(check)
|
||||
|
||||
|
@ -34,16 +34,16 @@ module Cask
|
||||
end
|
||||
|
||||
def self.get_info(cask)
|
||||
output = title_info(cask) + "\n"
|
||||
output << Formatter.url(cask.homepage) + "\n" if cask.homepage
|
||||
output = +"#{title_info(cask)}\n"
|
||||
output << "#{Formatter.url(cask.homepage)}\n" if cask.homepage
|
||||
output << installation_info(cask)
|
||||
repo = repo_info(cask)
|
||||
output << repo + "\n" if repo
|
||||
output << "#{repo}\n" if repo
|
||||
output << name_info(cask)
|
||||
output << desc_info(cask)
|
||||
language = language_info(cask)
|
||||
output << language if language
|
||||
output << artifact_info(cask) + "\n"
|
||||
output << "#{artifact_info(cask)}\n"
|
||||
caveats = Installer.caveats(cask)
|
||||
output << caveats if caveats
|
||||
output
|
||||
|
@ -19,7 +19,7 @@ module Cask
|
||||
def run
|
||||
outdated_casks = casks(alternative: -> { Caskroom.casks }).select do |cask|
|
||||
odebug "Checking update info of Cask #{cask}"
|
||||
cask.outdated?(args.greedy?)
|
||||
cask.outdated?(greedy: args.greedy?)
|
||||
end
|
||||
|
||||
verbose = ($stdout.tty? || args.verbose?) && !args.quiet?
|
||||
|
@ -54,13 +54,13 @@ module Cask
|
||||
|
||||
outdated_casks = if casks.empty?
|
||||
Caskroom.casks.select do |cask|
|
||||
cask.outdated?(greedy)
|
||||
cask.outdated?(greedy: greedy)
|
||||
end
|
||||
else
|
||||
casks.select do |cask|
|
||||
raise CaskNotInstalledError, cask unless cask.installed? || force
|
||||
|
||||
cask.outdated?(true)
|
||||
cask.outdated?(greedy: true)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -292,7 +292,7 @@ module Cask
|
||||
end
|
||||
|
||||
def respond_to_missing?(*)
|
||||
true
|
||||
super || true
|
||||
end
|
||||
|
||||
def appdir
|
||||
|
@ -30,7 +30,7 @@ module Cask
|
||||
end
|
||||
|
||||
def respond_to_missing?(*)
|
||||
true
|
||||
super || true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -5,6 +5,8 @@ module Cask
|
||||
|
||||
class MultipleCaskErrors < CaskError
|
||||
def initialize(errors)
|
||||
super
|
||||
|
||||
@errors = errors
|
||||
end
|
||||
|
||||
@ -20,6 +22,8 @@ module Cask
|
||||
attr_reader :token, :reason
|
||||
|
||||
def initialize(token, reason = nil)
|
||||
super()
|
||||
|
||||
@token = token
|
||||
@reason = reason.to_s
|
||||
end
|
||||
@ -168,6 +172,8 @@ module Cask
|
||||
attr_reader :path, :reason
|
||||
|
||||
def initialize(path, reason)
|
||||
super
|
||||
|
||||
@path = path
|
||||
@reason = reason
|
||||
end
|
||||
|
@ -85,7 +85,7 @@ module Cask
|
||||
poo << "during #{section}" if section
|
||||
poo << "on Cask #{token}."
|
||||
|
||||
opoo(poo.join(" ") + "\n" + error_message_with_suggestions)
|
||||
opoo("#{poo.join(" ")}\n#{error_message_with_suggestions}")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -17,7 +17,7 @@ class Caveats
|
||||
build = f.build
|
||||
f.build = Tab.for_formula(f)
|
||||
s = f.caveats.to_s
|
||||
caveats << s.chomp + "\n" unless s.empty?
|
||||
caveats << "#{s.chomp}\n" unless s.empty?
|
||||
ensure
|
||||
f.build = build
|
||||
end
|
||||
|
@ -28,7 +28,7 @@ class Cleaner
|
||||
[@f.bin, @f.sbin, @f.lib].each { |d| clean_dir(d) if d.exist? }
|
||||
|
||||
# Get rid of any info 'dir' files, so they don't conflict at the link stage
|
||||
info_dir_file = @f.info + "dir"
|
||||
info_dir_file = @f.info/"dir"
|
||||
observe_file_removal info_dir_file if info_dir_file.file? && !@f.skip_clean?(info_dir_file)
|
||||
|
||||
prune
|
||||
|
@ -48,7 +48,7 @@ module Homebrew
|
||||
mtime < days.days.ago && ctime < days.days.ago
|
||||
end
|
||||
|
||||
def stale?(scrub = false)
|
||||
def stale?(scrub: false)
|
||||
return false unless resolved_path.file?
|
||||
|
||||
if dirname.basename.to_s == "Cask"
|
||||
@ -308,7 +308,7 @@ module Homebrew
|
||||
next
|
||||
end
|
||||
|
||||
next cleanup_path(path) { path.unlink } if path.stale?(scrub?)
|
||||
next cleanup_path(path) { path.unlink } if path.stale?(scrub: scrub?)
|
||||
end
|
||||
|
||||
cleanup_unreferenced_downloads
|
||||
|
@ -142,9 +142,9 @@ module Homebrew
|
||||
if @table[switch] == true || @table[flag] == true
|
||||
@cli_args << option
|
||||
elsif @table[flag].instance_of? String
|
||||
@cli_args << option + "=" + @table[flag]
|
||||
@cli_args << "#{option}=#{@table[flag]}"
|
||||
elsif @table[flag].instance_of? Array
|
||||
@cli_args << option + "=" + @table[flag].join(",")
|
||||
@cli_args << "#{option}=#{@table[flag].join(",")}"
|
||||
end
|
||||
end
|
||||
@cli_args.freeze
|
||||
|
@ -11,7 +11,7 @@ module Homebrew
|
||||
@force_bottle = force_bottle
|
||||
@flags = flags
|
||||
|
||||
__setobj__(@args)
|
||||
super(@args)
|
||||
end
|
||||
|
||||
def to_formulae
|
||||
|
@ -83,26 +83,26 @@ module Homebrew
|
||||
raise FormulaUnspecifiedError
|
||||
end
|
||||
|
||||
puts_deps_tree dependents, recursive, args: args
|
||||
puts_deps_tree dependents, recursive: recursive, args: args
|
||||
return
|
||||
elsif args.all?
|
||||
puts_deps sorted_dependents(Formula.to_a + Cask::Cask.to_a), recursive, args: args
|
||||
puts_deps sorted_dependents(Formula.to_a + Cask::Cask.to_a), recursive: recursive, args: args
|
||||
return
|
||||
elsif !args.no_named? && args.for_each?
|
||||
puts_deps sorted_dependents(args.formulae_and_casks), recursive, args: args
|
||||
puts_deps sorted_dependents(args.formulae_and_casks), recursive: recursive, args: args
|
||||
return
|
||||
end
|
||||
|
||||
if args.no_named?
|
||||
raise FormulaUnspecifiedError unless args.installed?
|
||||
|
||||
puts_deps sorted_dependents(Formula.installed + Cask::Caskroom.casks), recursive, args: args
|
||||
puts_deps sorted_dependents(Formula.installed + Cask::Caskroom.casks), recursive: recursive, args: args
|
||||
return
|
||||
end
|
||||
|
||||
dependents = dependents(args.formulae_and_casks)
|
||||
|
||||
all_deps = deps_for_dependents(dependents, recursive, args: args, &(args.union? ? :| : :&))
|
||||
all_deps = deps_for_dependents(dependents, recursive: recursive, args: args, &(args.union? ? :| : :&))
|
||||
condense_requirements(all_deps, args: args)
|
||||
all_deps.map! { |d| dep_display_name(d, args: args) }
|
||||
all_deps.uniq!
|
||||
@ -144,7 +144,7 @@ module Homebrew
|
||||
str
|
||||
end
|
||||
|
||||
def deps_for_dependent(d, recursive = false, args:)
|
||||
def deps_for_dependent(d, recursive: false, args:)
|
||||
includes, ignores = args_includes_ignores(args)
|
||||
|
||||
deps = d.runtime_dependencies if @use_runtime_dependencies
|
||||
@ -160,13 +160,13 @@ module Homebrew
|
||||
deps + reqs.to_a
|
||||
end
|
||||
|
||||
def deps_for_dependents(dependents, recursive = false, args:, &block)
|
||||
dependents.map { |d| deps_for_dependent(d, recursive, args: args) }.reduce(&block)
|
||||
def deps_for_dependents(dependents, recursive: false, args:, &block)
|
||||
dependents.map { |d| deps_for_dependent(d, recursive: recursive, args: args) }.reduce(&block)
|
||||
end
|
||||
|
||||
def puts_deps(dependents, recursive = false, args:)
|
||||
def puts_deps(dependents, recursive: false, args:)
|
||||
dependents.each do |dependent|
|
||||
deps = deps_for_dependent(dependent, recursive, args: args)
|
||||
deps = deps_for_dependent(dependent, recursive: recursive, args: args)
|
||||
condense_requirements(deps, args: args)
|
||||
deps.sort_by!(&:name)
|
||||
deps.map! { |d| dep_display_name(d, args: args) }
|
||||
@ -174,7 +174,7 @@ module Homebrew
|
||||
end
|
||||
end
|
||||
|
||||
def puts_deps_tree(dependents, recursive = false, args:)
|
||||
def puts_deps_tree(dependents, recursive: false, args:)
|
||||
dependents.each do |d|
|
||||
puts d.full_name
|
||||
@dep_stack = []
|
||||
|
@ -31,7 +31,7 @@ module Homebrew
|
||||
|
||||
inject_dump_stats!(Diagnostic::Checks, /^check_*/) if args.audit_debug?
|
||||
|
||||
checks = Diagnostic::Checks.new args.verbose?
|
||||
checks = Diagnostic::Checks.new(verbose: args.verbose?)
|
||||
|
||||
if args.list_checks?
|
||||
puts checks.all.sort
|
||||
|
@ -179,7 +179,7 @@ module Commands
|
||||
cmds = internal_commands + internal_developer_commands + internal_commands_aliases
|
||||
|
||||
file = HOMEBREW_REPOSITORY/"completions/internal_commands_list.txt"
|
||||
file.atomic_write(cmds.sort.join("\n") + "\n")
|
||||
file.atomic_write("#{cmds.sort.join("\n")}\n")
|
||||
end
|
||||
|
||||
def rebuild_commands_completion_list
|
||||
@ -187,6 +187,6 @@ module Commands
|
||||
HOMEBREW_CACHE.mkpath
|
||||
|
||||
file = HOMEBREW_CACHE/"all_commands_list.txt"
|
||||
file.atomic_write(commands(aliases: true).sort.join("\n") + "\n")
|
||||
file.atomic_write("#{commands(aliases: true).sort.join("\n")}\n")
|
||||
end
|
||||
end
|
||||
|
@ -544,7 +544,7 @@ module Homebrew
|
||||
)\n+ # multiple empty lines
|
||||
)+
|
||||
/mx
|
||||
string = s.sub!(pattern, '\0' + output + "\n")
|
||||
string = s.sub!(pattern, "\\0#{output}\n")
|
||||
odie "Bottle block addition failed!" unless string
|
||||
end
|
||||
end
|
||||
|
@ -378,7 +378,8 @@ module Homebrew
|
||||
EOS
|
||||
user_message = args.message
|
||||
if user_message
|
||||
pr_message += "\n" + <<~EOS
|
||||
pr_message += <<~EOS
|
||||
|
||||
---
|
||||
|
||||
#{user_message}
|
||||
|
@ -65,7 +65,7 @@ module Homebrew
|
||||
revision: "#{formula_spec.specs[:revision]}"
|
||||
EOS
|
||||
end
|
||||
replacement = old + " revision 1\n"
|
||||
replacement = "#{old} revision 1\n"
|
||||
|
||||
else
|
||||
old = "revision #{current_revision}"
|
||||
|
@ -205,7 +205,7 @@ module Homebrew
|
||||
def initialize(url, args, description = nil)
|
||||
@base_url = url
|
||||
# GitHub provides commits/pull-requests raw patches using this URL.
|
||||
@patch_url = url + ".patch"
|
||||
@patch_url = "#{url}.patch"
|
||||
@patchpath = HOMEBREW_CACHE + File.basename(patch_url)
|
||||
@description = description
|
||||
@args = args
|
||||
|
@ -30,7 +30,7 @@ module Homebrew
|
||||
|
||||
# Diagnostic checks.
|
||||
class Checks
|
||||
def initialize(verbose = true)
|
||||
def initialize(verbose: true)
|
||||
@verbose = verbose
|
||||
end
|
||||
|
||||
|
@ -345,7 +345,7 @@ class CurlDownloadStrategy < AbstractFileDownloadStrategy
|
||||
return @resolved_info_cache[url] if @resolved_info_cache.include?(url)
|
||||
|
||||
if (domain = Homebrew::EnvConfig.artifact_domain)
|
||||
url = url.sub(%r{^((ht|f)tps?://)?}, domain.chomp("/") + "/")
|
||||
url = url.sub(%r{^((ht|f)tps?://)?}, "#{domain.chomp("/")}/")
|
||||
end
|
||||
|
||||
out, _, status= curl_output("--location", "--silent", "--head", "--request", "GET", url.to_s)
|
||||
@ -503,7 +503,7 @@ end
|
||||
|
||||
# This strategy extracts local binary packages.
|
||||
class LocalBottleDownloadStrategy < AbstractFileDownloadStrategy
|
||||
def initialize(path)
|
||||
def initialize(path) # rubocop:disable Lint/MissingSuper
|
||||
@cached_location = path
|
||||
end
|
||||
end
|
||||
@ -552,7 +552,7 @@ class SubversionDownloadStrategy < VCSDownloadStrategy
|
||||
end
|
||||
end
|
||||
|
||||
def fetch_repo(target, url, revision = nil, ignore_externals = false)
|
||||
def fetch_repo(target, url, revision = nil, ignore_externals: false)
|
||||
# Use "svn update" when the repository already exists locally.
|
||||
# This saves on bandwidth and will have a similar effect to verifying the
|
||||
# cache as it will make any changes to get the right revision.
|
||||
@ -593,10 +593,10 @@ class SubversionDownloadStrategy < VCSDownloadStrategy
|
||||
when :revisions
|
||||
# nil is OK for main_revision, as fetch_repo will then get latest
|
||||
main_revision = @ref[:trunk]
|
||||
fetch_repo cached_location, @url, main_revision, true
|
||||
fetch_repo cached_location, @url, main_revision, ignore_externals: true
|
||||
|
||||
externals do |external_name, external_url|
|
||||
fetch_repo cached_location/external_name, external_url, @ref[external_name], true
|
||||
fetch_repo cached_location/external_name, external_url, @ref[external_name], ignore_externals: true
|
||||
end
|
||||
else
|
||||
fetch_repo cached_location, @url
|
||||
|
@ -7,6 +7,8 @@ class UsageError < RuntimeError
|
||||
attr_reader :reason
|
||||
|
||||
def initialize(reason = nil)
|
||||
super
|
||||
|
||||
@reason = reason
|
||||
end
|
||||
|
||||
@ -63,6 +65,8 @@ class FormulaUnavailableError < RuntimeError
|
||||
attr_accessor :dependent
|
||||
|
||||
def initialize(name)
|
||||
super
|
||||
|
||||
@name = name
|
||||
end
|
||||
|
||||
|
@ -84,7 +84,7 @@ module Hardware
|
||||
end
|
||||
|
||||
%w[aes altivec avx avx2 lm ssse3 sse4_2].each do |flag|
|
||||
define_method(flag + "?") { flags.include? flag }
|
||||
define_method("#{flag}?") { flags.include? flag }
|
||||
end
|
||||
|
||||
def sse3?
|
||||
|
@ -22,8 +22,8 @@ class OsxfuseRequirement < Requirement
|
||||
def message
|
||||
msg = "libfuse is required to install this formula.\n"
|
||||
if libfuse_formula_exists?
|
||||
msg + <<~EOS
|
||||
Run `brew install libfuse` to install it.
|
||||
<<~EOS
|
||||
#{msg}Run `brew install libfuse` to install it.
|
||||
EOS
|
||||
else
|
||||
msg + super
|
||||
|
@ -44,6 +44,6 @@ class Caveats
|
||||
s << "" << "WARNING: brew services will fail when run under tmux."
|
||||
end
|
||||
end
|
||||
s.join("\n") + "\n" unless s.empty?
|
||||
"#{s.join("\n")}\n" unless s.empty?
|
||||
end
|
||||
end
|
||||
|
@ -22,7 +22,7 @@ class StringInreplaceExtension
|
||||
end
|
||||
|
||||
# Warn if nothing was replaced
|
||||
def gsub!(before, after, audit_result = true)
|
||||
def gsub!(before, after, audit_result = true) # rubocop:disable Style/OptionalBooleanParameter
|
||||
result = inreplace_string.gsub!(before, after)
|
||||
errors << "expected replacement of #{before.inspect} with #{after.inspect}" if audit_result && result.nil?
|
||||
result
|
||||
|
@ -944,12 +944,12 @@ class Formula
|
||||
|
||||
# The generated launchd {.plist} service name.
|
||||
def plist_name
|
||||
"homebrew.mxcl." + name
|
||||
"homebrew.mxcl.#{name}"
|
||||
end
|
||||
|
||||
# The generated launchd {.plist} file path.
|
||||
def plist_path
|
||||
prefix + (plist_name + ".plist")
|
||||
prefix/"#{plist_name}.plist"
|
||||
end
|
||||
|
||||
# @private
|
||||
@ -1137,7 +1137,7 @@ class Formula
|
||||
to_check = path.relative_path_from(HOMEBREW_PREFIX).to_s
|
||||
self.class.link_overwrite_paths.any? do |p|
|
||||
p == to_check ||
|
||||
to_check.start_with?(p.chomp("/") + "/") ||
|
||||
to_check.start_with?("#{p.chomp("/")}/") ||
|
||||
to_check =~ /^#{Regexp.escape(p).gsub('\*', ".*?")}$/
|
||||
end
|
||||
end
|
||||
@ -2070,21 +2070,17 @@ class Formula
|
||||
# recursively delete the temporary directory. Passing `opts[:retain]`
|
||||
# or calling `do |staging| ... staging.retain!` in the block will skip
|
||||
# the deletion and retain the temporary directory's contents.
|
||||
def mktemp(prefix = name, opts = {})
|
||||
Mktemp.new(prefix, opts).run do |staging|
|
||||
yield staging
|
||||
end
|
||||
def mktemp(prefix = name, opts = {}, &block)
|
||||
Mktemp.new(prefix, opts).run(&block)
|
||||
end
|
||||
|
||||
# A version of `FileUtils.mkdir` that also changes to that folder in
|
||||
# a block.
|
||||
def mkdir(name)
|
||||
def mkdir(name, &block)
|
||||
result = FileUtils.mkdir_p(name)
|
||||
return result unless block_given?
|
||||
|
||||
FileUtils.chdir name do
|
||||
yield
|
||||
end
|
||||
FileUtils.chdir(name, &block)
|
||||
end
|
||||
|
||||
# Run `xcodebuild` without Homebrew's compiler environment variables set.
|
||||
@ -2184,6 +2180,8 @@ class Formula
|
||||
include BuildEnvironment::DSL
|
||||
|
||||
def method_added(method)
|
||||
super
|
||||
|
||||
case method
|
||||
when :brew
|
||||
raise "You cannot override Formula#brew in class #{name}"
|
||||
|
@ -362,10 +362,10 @@ class Keg
|
||||
ObserverPathnameExtension.n
|
||||
end
|
||||
|
||||
def lock
|
||||
def lock(&block)
|
||||
FormulaLock.new(name).with_lock do
|
||||
if oldname_opt_record
|
||||
FormulaLock.new(oldname_opt_record.basename.to_s).with_lock { yield }
|
||||
FormulaLock.new(oldname_opt_record.basename.to_s).with_lock(&block)
|
||||
else
|
||||
yield
|
||||
end
|
||||
|
@ -126,10 +126,8 @@ class Requirement
|
||||
name
|
||||
end
|
||||
|
||||
def mktemp
|
||||
Mktemp.new(name).run do |staging|
|
||||
yield staging
|
||||
end
|
||||
def mktemp(&block)
|
||||
Mktemp.new(name).run(&block)
|
||||
end
|
||||
|
||||
private
|
||||
|
@ -193,10 +193,8 @@ class Resource
|
||||
|
||||
protected
|
||||
|
||||
def mktemp(prefix)
|
||||
Mktemp.new(prefix).run do |staging|
|
||||
yield staging
|
||||
end
|
||||
def mktemp(prefix, &block)
|
||||
Mktemp.new(prefix).run(&block)
|
||||
end
|
||||
|
||||
private
|
||||
|
@ -467,7 +467,7 @@ module RuboCop
|
||||
|
||||
fileutils_methods = Regexp.new(
|
||||
FileUtils.singleton_methods(false)
|
||||
.map { |m| "(?-mix:^" + Regexp.escape(m) + "$)" }
|
||||
.map { |m| "(?-mix:^#{Regexp.escape(m)}$)" }
|
||||
.join("|"),
|
||||
)
|
||||
find_every_method_call_by_name(body_node, :system).each do |method|
|
||||
|
@ -71,7 +71,9 @@ class SystemCommand
|
||||
@options = options
|
||||
@env = env
|
||||
|
||||
@env.keys.grep_v(/^[\w&&\D]\w*$/) do |name|
|
||||
@env.each_key do |name|
|
||||
next if /^[\w&&\D]\w*$/.match?(name)
|
||||
|
||||
raise ArgumentError, "Invalid variable name: '#{name}'"
|
||||
end
|
||||
end
|
||||
|
@ -134,7 +134,7 @@ describe Cask::Cask, :cask do
|
||||
expectations.each do |installed_version, expected_output|
|
||||
context "when versions #{installed_version} are installed and the " \
|
||||
"tap version is #{tap_version}, #{"not" unless greedy} greedy" do
|
||||
subject { cask.outdated_versions greedy }
|
||||
subject { cask.outdated_versions(greedy: greedy) }
|
||||
|
||||
it {
|
||||
allow(cask).to receive(:versions).and_return(installed_version)
|
||||
|
@ -111,7 +111,7 @@ describe Cask::Cmd::Outdated, :cask do
|
||||
|
||||
expect {
|
||||
described_class.run("--json")
|
||||
}.to output(result + "\n").to_stdout
|
||||
}.to output("#{result}\n").to_stdout
|
||||
end
|
||||
end
|
||||
|
||||
@ -132,7 +132,7 @@ describe Cask::Cmd::Outdated, :cask do
|
||||
|
||||
expect {
|
||||
described_class.run("--json", "--quiet")
|
||||
}.to output(result + "\n").to_stdout
|
||||
}.to output("#{result}\n").to_stdout
|
||||
end
|
||||
end
|
||||
|
||||
@ -163,7 +163,7 @@ describe Cask::Cmd::Outdated, :cask do
|
||||
|
||||
expect {
|
||||
described_class.run("--json", "--greedy")
|
||||
}.to output(result + "\n").to_stdout
|
||||
}.to output("#{result}\n").to_stdout
|
||||
end
|
||||
|
||||
it 'does not include the Casks with "auto_updates true" with no version change in JSON format' do
|
||||
@ -190,7 +190,7 @@ describe Cask::Cmd::Outdated, :cask do
|
||||
|
||||
expect {
|
||||
described_class.run("--json", "--greedy")
|
||||
}.to output(result + "\n").to_stdout
|
||||
}.to output("#{result}\n").to_stdout
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -233,7 +233,7 @@ describe Cask::Installer, :cask do
|
||||
|
||||
it "uninstalls all versions if force is set" do
|
||||
caffeine = Cask::CaskLoader.load(cask_path("local-caffeine"))
|
||||
mutated_version = caffeine.version + ".1"
|
||||
mutated_version = "#{caffeine.version}.1"
|
||||
|
||||
described_class.new(caffeine).install
|
||||
|
||||
|
@ -287,7 +287,7 @@ describe Homebrew::CLI::Parser do
|
||||
|
||||
context "kegs" do
|
||||
before do
|
||||
keg = HOMEBREW_CELLAR + "mxcl/10.0"
|
||||
keg = HOMEBREW_CELLAR/"mxcl/10.0"
|
||||
keg.mkpath
|
||||
end
|
||||
|
||||
|
@ -22,7 +22,7 @@ describe "brew outdated", :integration_test do
|
||||
].to_json
|
||||
|
||||
expect { brew "outdated", "--json=v1" }
|
||||
.to output(expected_json + "\n").to_stdout
|
||||
.to output("#{expected_json}\n").to_stdout
|
||||
.and be_a_success
|
||||
end
|
||||
end
|
||||
|
@ -266,16 +266,12 @@ module Kernel
|
||||
raise $CHILD_STATUS.inspect
|
||||
end
|
||||
|
||||
def with_homebrew_path
|
||||
with_env(PATH: PATH.new(ENV["HOMEBREW_PATH"])) do
|
||||
yield
|
||||
end
|
||||
def with_homebrew_path(&block)
|
||||
with_env(PATH: PATH.new(ENV["HOMEBREW_PATH"]), &block)
|
||||
end
|
||||
|
||||
def with_custom_locale(locale)
|
||||
with_env(LC_ALL: locale) do
|
||||
yield
|
||||
end
|
||||
def with_custom_locale(locale, &block)
|
||||
with_env(LC_ALL: locale, &block)
|
||||
end
|
||||
|
||||
# Kernel.system but with exceptions
|
||||
|
@ -47,8 +47,8 @@ module Formatter
|
||||
indent = width - desc
|
||||
s.gsub(/(?<=\S) *\n(?=\S)/, " ")
|
||||
.gsub(/([`>)\]]:) /, "\\1\n ")
|
||||
.gsub(/^( +-.+ +(?=\S.{#{desc}}))(.{1,#{desc}})( +|$)\n?/, "\\1\\2\n" + " " * indent)
|
||||
.gsub(/^( {#{indent}}(?=\S.{#{desc}}))(.{1,#{desc}})( +|$)\n?/, "\\1\\2\n" + " " * indent)
|
||||
.gsub(/^( +-.+ +(?=\S.{#{desc}}))(.{1,#{desc}})( +|$)\n?/, "\\1\\2\n#{" " * indent}")
|
||||
.gsub(/^( {#{indent}}(?=\S.{#{desc}}))(.{1,#{desc}})( +|$)\n?/, "\\1\\2\n#{" " * indent}")
|
||||
.gsub(/(.{1,#{width}})( +|$)\n?/, "\\1\n")
|
||||
end
|
||||
|
||||
|
@ -21,7 +21,7 @@ module Utils
|
||||
#
|
||||
# `inreplace` supports regular expressions:
|
||||
# <pre>inreplace "somefile.cfg", /look[for]what?/, "replace by #{bin}/tool"</pre>
|
||||
def inreplace(paths, before = nil, after = nil, audit_result = true)
|
||||
def inreplace(paths, before = nil, after = nil, audit_result = true) # rubocop:disable Style/OptionalBooleanParameter
|
||||
errors = {}
|
||||
|
||||
errors["`paths` (first) parameter"] = ["`paths` was empty"] if paths.blank?
|
||||
|
@ -92,7 +92,7 @@ module Utils
|
||||
|
||||
str = str.dup
|
||||
# anything that isn't a known safe character is padded
|
||||
str.gsub!(UNSAFE_SHELL_CHAR, "\\\\" + "\\1")
|
||||
str.gsub!(UNSAFE_SHELL_CHAR, "\\\\" + "\\1") # rubocop:disable Style/StringConcatenation
|
||||
# newlines have to be specially quoted in csh
|
||||
str.gsub!(/\n/, "'\\\n'")
|
||||
str
|
||||
@ -105,7 +105,7 @@ module Utils
|
||||
|
||||
str = str.dup
|
||||
# anything that isn't a known safe character is padded
|
||||
str.gsub!(UNSAFE_SHELL_CHAR, "\\\\" + "\\1")
|
||||
str.gsub!(UNSAFE_SHELL_CHAR, "\\\\" + "\\1") # rubocop:disable Style/StringConcatenation
|
||||
str.gsub!(/\n/, "'\n'")
|
||||
str
|
||||
end
|
||||
|
@ -102,6 +102,8 @@ class Version
|
||||
PATTERN = /[a-z]+/i.freeze
|
||||
|
||||
def initialize(value)
|
||||
super
|
||||
|
||||
@value = value.to_s
|
||||
end
|
||||
|
||||
@ -121,6 +123,8 @@ class Version
|
||||
PATTERN = /[0-9]+/i.freeze
|
||||
|
||||
def initialize(value)
|
||||
super
|
||||
|
||||
@value = value.to_i
|
||||
end
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user