Fix RuboCop offenses.
This commit is contained in:
parent
e41b3e8741
commit
0184e271d8
@ -163,6 +163,10 @@ Performance/CaseWhenSplat:
|
||||
Performance/Caller:
|
||||
Enabled: false
|
||||
|
||||
# Makes code less readable for minor performance increases.
|
||||
Performance/MethodObjectAsBlock:
|
||||
Enabled: false
|
||||
|
||||
# Don't allow cops to be disabled in casks and formulae.
|
||||
Style/DisableCopsWithinSourceCodeDirective:
|
||||
Enabled: true
|
||||
|
||||
@ -22,7 +22,7 @@ module Cask
|
||||
attr_reader :token, :sourcefile_path, :config, :default_config
|
||||
|
||||
def self.each(&block)
|
||||
return to_enum unless block_given?
|
||||
return to_enum unless block
|
||||
|
||||
Tap.flat_map(&:cask_files).each do |f|
|
||||
block.call CaskLoader::FromTapPathLoader.new(f).load(config: nil)
|
||||
|
||||
@ -84,7 +84,7 @@ module Cask
|
||||
|
||||
def self.parser(&block)
|
||||
Homebrew::CLI::Parser.new do
|
||||
if block_given?
|
||||
if block
|
||||
instance_eval(&block)
|
||||
else
|
||||
usage_banner <<~EOS
|
||||
|
||||
@ -68,7 +68,7 @@ module Cask
|
||||
Cmd.parser do
|
||||
usage_banner banner
|
||||
|
||||
instance_eval(&block) if block_given?
|
||||
instance_eval(&block) if block
|
||||
|
||||
OPTIONS.each do |option|
|
||||
send(*option)
|
||||
|
||||
@ -34,7 +34,7 @@ module Cask
|
||||
send(*option)
|
||||
end
|
||||
|
||||
instance_eval(&block) if block_given?
|
||||
instance_eval(&block) if block
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@ -125,7 +125,7 @@ module Cask
|
||||
def language(*args, default: false, &block)
|
||||
if args.empty?
|
||||
language_eval
|
||||
elsif block_given?
|
||||
elsif block
|
||||
@language_blocks ||= {}
|
||||
@language_blocks[args] = block
|
||||
|
||||
@ -248,7 +248,7 @@ module Cask
|
||||
|
||||
def caveats(*strings, &block)
|
||||
@caveats ||= DSL::Caveats.new(cask)
|
||||
if block_given?
|
||||
if block
|
||||
@caveats.eval_caveats(&block)
|
||||
elsif strings.any?
|
||||
strings.each do |string|
|
||||
|
||||
@ -136,7 +136,7 @@ module Homebrew
|
||||
switch short, long, description: desc, env: option_to_name(long), method: :on_tail
|
||||
end
|
||||
|
||||
instance_eval(&block) if block_given?
|
||||
instance_eval(&block) if block
|
||||
end
|
||||
|
||||
def switch(*names, description: nil, env: nil, required_for: nil, depends_on: nil, method: :on)
|
||||
|
||||
@ -56,7 +56,7 @@ class CompilerFailure
|
||||
def initialize(name, version, &block)
|
||||
@name = name
|
||||
@version = Version.parse(version.to_s)
|
||||
instance_eval(&block) if block_given?
|
||||
instance_eval(&block) if block
|
||||
end
|
||||
|
||||
def fails_with?(compiler)
|
||||
|
||||
@ -120,9 +120,9 @@ class Dependency
|
||||
@expand_stack.pop
|
||||
end
|
||||
|
||||
def action(dependent, dep, &_block)
|
||||
def action(dependent, dep, &block)
|
||||
catch(:action) do
|
||||
if block_given?
|
||||
if block
|
||||
yield dependent, dep
|
||||
elsif dep.optional? || dep.recommended?
|
||||
prune unless dependent.build.with?(dep)
|
||||
|
||||
@ -4,8 +4,8 @@
|
||||
class Formula
|
||||
undef on_linux
|
||||
|
||||
def on_linux(&_block)
|
||||
raise "No block content defined for on_linux block" unless block_given?
|
||||
def on_linux(&block)
|
||||
raise "No block content defined for on_linux block" unless block
|
||||
|
||||
yield
|
||||
end
|
||||
@ -19,8 +19,8 @@ class Formula
|
||||
class << self
|
||||
undef on_linux
|
||||
|
||||
def on_linux(&_block)
|
||||
raise "No block content defined for on_linux block" unless block_given?
|
||||
def on_linux(&block)
|
||||
raise "No block content defined for on_linux block" unless block
|
||||
|
||||
yield
|
||||
end
|
||||
|
||||
@ -4,8 +4,8 @@
|
||||
class Formula
|
||||
undef on_macos
|
||||
|
||||
def on_macos(&_block)
|
||||
raise "No block content defined for on_macos block" unless block_given?
|
||||
def on_macos(&block)
|
||||
raise "No block content defined for on_macos block" unless block
|
||||
|
||||
yield
|
||||
end
|
||||
@ -13,8 +13,8 @@ class Formula
|
||||
class << self
|
||||
undef on_macos
|
||||
|
||||
def on_macos(&_block)
|
||||
raise "No block content defined for on_macos block" unless block_given?
|
||||
def on_macos(&block)
|
||||
raise "No block content defined for on_macos block" unless block
|
||||
|
||||
yield
|
||||
end
|
||||
|
||||
@ -282,7 +282,7 @@ class Formula
|
||||
# and is specified to this instance.
|
||||
def installed_alias_path
|
||||
path = build.source["path"] if build.is_a?(Tab)
|
||||
return unless path&.match?(%r{#{HOMEBREW_TAP_DIR_REGEX}/Aliases})
|
||||
return unless path&.match?(%r{#{HOMEBREW_TAP_DIR_REGEX}/Aliases}o)
|
||||
return unless File.symlink?(path)
|
||||
|
||||
path
|
||||
@ -1384,16 +1384,16 @@ class Formula
|
||||
# <pre>on_macos do
|
||||
# # Do something Mac-specific
|
||||
# end</pre>
|
||||
def on_macos(&_block)
|
||||
raise "No block content defined for on_macos block" unless block_given?
|
||||
def on_macos(&block)
|
||||
raise "No block content defined for on_macos block" unless block
|
||||
end
|
||||
|
||||
# Block only executed on Linux. No-op on macOS.
|
||||
# <pre>on_linux do
|
||||
# # Do something Linux-specific
|
||||
# end</pre>
|
||||
def on_linux(&_block)
|
||||
raise "No block content defined for on_linux block" unless block_given?
|
||||
def on_linux(&block)
|
||||
raise "No block content defined for on_linux block" unless block
|
||||
end
|
||||
|
||||
# Standard parameters for cargo builds.
|
||||
@ -2118,7 +2118,7 @@ class Formula
|
||||
# a block.
|
||||
def mkdir(name, &block)
|
||||
result = FileUtils.mkdir_p(name)
|
||||
return result unless block_given?
|
||||
return result unless block
|
||||
|
||||
FileUtils.chdir(name, &block)
|
||||
end
|
||||
@ -2458,7 +2458,7 @@ class Formula
|
||||
# end</pre>
|
||||
def stable(&block)
|
||||
@stable ||= SoftwareSpec.new(flags: build_flags)
|
||||
return @stable unless block_given?
|
||||
return @stable unless block
|
||||
|
||||
@stable.instance_eval(&block)
|
||||
end
|
||||
@ -2482,7 +2482,7 @@ class Formula
|
||||
# <pre>head "https://hg.is.awesome.but.git.has.won.example.com/", using: :hg</pre>
|
||||
def head(val = nil, specs = {}, &block)
|
||||
@head ||= HeadSoftwareSpec.new(flags: build_flags)
|
||||
if block_given?
|
||||
if block
|
||||
@head.instance_eval(&block)
|
||||
elsif val
|
||||
@head.url(val, specs)
|
||||
@ -2553,16 +2553,16 @@ class Formula
|
||||
# <pre>on_macos do
|
||||
# depends_on "mac_only_dep"
|
||||
# end</pre>
|
||||
def on_macos(&_block)
|
||||
raise "No block content defined for on_macos block" unless block_given?
|
||||
def on_macos(&block)
|
||||
raise "No block content defined for on_macos block" unless block
|
||||
end
|
||||
|
||||
# Block only executed on Linux. No-op on macOS.
|
||||
# <pre>on_linux do
|
||||
# depends_on "linux_only_dep"
|
||||
# end</pre>
|
||||
def on_linux(&_block)
|
||||
raise "No block content defined for on_linux block" unless block_given?
|
||||
def on_linux(&block)
|
||||
raise "No block content defined for on_linux block" unless block
|
||||
end
|
||||
|
||||
# @!attribute [w] option
|
||||
@ -2757,7 +2757,7 @@ class Formula
|
||||
# end</pre>
|
||||
def livecheck(&block)
|
||||
@livecheck ||= Livecheck.new(self)
|
||||
return @livecheck unless block_given?
|
||||
return @livecheck unless block
|
||||
|
||||
@livecheckable = true
|
||||
@livecheck.instance_eval(&block)
|
||||
|
||||
@ -270,7 +270,7 @@ module Language
|
||||
next unless f.symlink?
|
||||
next unless (rp = f.realpath.to_s).start_with? HOMEBREW_CELLAR
|
||||
|
||||
version = rp.match %r{^#{HOMEBREW_CELLAR}/python@(.*?)/}
|
||||
version = rp.match %r{^#{HOMEBREW_CELLAR}/python@(.*?)/}o
|
||||
version = "@#{version.captures.first}" unless version.nil?
|
||||
|
||||
new_target = rp.sub %r{#{HOMEBREW_CELLAR}/python#{version}/[^/]+}, Formula["python#{version}"].opt_prefix
|
||||
@ -281,7 +281,7 @@ module Language
|
||||
Pathname.glob(@venv_root/"lib/python*/orig-prefix.txt").each do |prefix_file|
|
||||
prefix_path = prefix_file.read
|
||||
|
||||
version = prefix_path.match %r{^#{HOMEBREW_CELLAR}/python@(.*?)/}
|
||||
version = prefix_path.match %r{^#{HOMEBREW_CELLAR}/python@(.*?)/}o
|
||||
version = "@#{version.captures.first}" unless version.nil?
|
||||
|
||||
prefix_path.sub! %r{^#{HOMEBREW_CELLAR}/python#{version}/[^/]+}, Formula["python#{version}"].opt_prefix
|
||||
|
||||
@ -129,7 +129,7 @@ class LinkageChecker
|
||||
private
|
||||
|
||||
def dylib_to_dep(dylib)
|
||||
dylib =~ %r{#{Regexp.escape(HOMEBREW_PREFIX)}/(opt|Cellar)/([\w+-.@]+)/}
|
||||
dylib =~ %r{#{Regexp.escape(HOMEBREW_PREFIX)}/(opt|Cellar)/([\w+-.@]+)/}o
|
||||
Regexp.last_match(2)
|
||||
end
|
||||
|
||||
|
||||
@ -82,7 +82,7 @@ class Requirement
|
||||
return unless @satisfied_result.is_a?(Pathname)
|
||||
|
||||
parent = @satisfied_result.resolved_path.parent
|
||||
if parent.to_s =~ %r{^#{Regexp.escape(HOMEBREW_CELLAR)}/([\w+-.@]+)/[^/]+/(s?bin)/?$}
|
||||
if parent.to_s =~ %r{^#{Regexp.escape(HOMEBREW_CELLAR)}/([\w+-.@]+)/[^/]+/(s?bin)/?$}o
|
||||
parent = HOMEBREW_PREFIX/"opt/#{Regexp.last_match(1)}/#{Regexp.last_match(2)}"
|
||||
end
|
||||
parent
|
||||
@ -168,14 +168,14 @@ class Requirement
|
||||
attr_rw :fatal, :cask, :download
|
||||
|
||||
def satisfy(options = nil, &block)
|
||||
return @satisfied if options.nil? && !block_given?
|
||||
return @satisfied if options.nil? && !block
|
||||
|
||||
options = {} if options.nil?
|
||||
@satisfied = Satisfier.new(options, &block)
|
||||
end
|
||||
|
||||
def env(*settings, &block)
|
||||
if block_given?
|
||||
if block
|
||||
@env_proc = block
|
||||
else
|
||||
super
|
||||
@ -236,9 +236,9 @@ class Requirement
|
||||
reqs
|
||||
end
|
||||
|
||||
def prune?(dependent, req, &_block)
|
||||
def prune?(dependent, req, &block)
|
||||
catch(:prune) do
|
||||
if block_given?
|
||||
if block
|
||||
yield dependent, req
|
||||
elsif req.optional? || req.recommended?
|
||||
prune unless dependent.build.with?(req)
|
||||
|
||||
@ -32,7 +32,7 @@ class Resource
|
||||
@checksum = nil
|
||||
@using = nil
|
||||
@patches = []
|
||||
instance_eval(&block) if block_given?
|
||||
instance_eval(&block) if block
|
||||
end
|
||||
|
||||
def owner=(owner)
|
||||
|
||||
@ -107,7 +107,7 @@ class SoftwareSpec
|
||||
end
|
||||
|
||||
def resource(name, klass = Resource, &block)
|
||||
if block_given?
|
||||
if block
|
||||
raise DuplicateResourceError, name if resource_defined?(name)
|
||||
|
||||
res = klass.new(name, &block)
|
||||
|
||||
@ -586,7 +586,7 @@ class Tap
|
||||
def self.each(&block)
|
||||
return unless TAP_DIRECTORY.directory?
|
||||
|
||||
return to_enum unless block_given?
|
||||
return to_enum unless block
|
||||
|
||||
TAP_DIRECTORY.subdirs.each do |user|
|
||||
user.subdirs.each do |repo|
|
||||
|
||||
@ -10,14 +10,14 @@ end
|
||||
describe "brew --cache", :integration_test do
|
||||
it "prints all cache files for a given Formula" do
|
||||
expect { brew "--cache", testball }
|
||||
.to output(%r{#{HOMEBREW_CACHE}/downloads/[\da-f]{64}--testball-}).to_stdout
|
||||
.to output(%r{#{HOMEBREW_CACHE}/downloads/[\da-f]{64}--testball-}o).to_stdout
|
||||
.and not_to_output.to_stderr
|
||||
.and be_a_success
|
||||
end
|
||||
|
||||
it "prints the cache files for a given Cask" do
|
||||
expect { brew "--cache", cask_path("local-caffeine") }
|
||||
.to output(%r{#{HOMEBREW_CACHE}/downloads/[\da-f]{64}--caffeine\.zip}).to_stdout
|
||||
.to output(%r{#{HOMEBREW_CACHE}/downloads/[\da-f]{64}--caffeine\.zip}o).to_stdout
|
||||
.and not_to_output.to_stderr
|
||||
.and be_a_success
|
||||
end
|
||||
@ -28,7 +28,7 @@ describe "brew --cache", :integration_test do
|
||||
%r{
|
||||
#{HOMEBREW_CACHE}/downloads/[\da-f]{64}--testball-.*\n
|
||||
#{HOMEBREW_CACHE}/downloads/[\da-f]{64}--caffeine\.zip
|
||||
}x,
|
||||
}xo,
|
||||
).to_stdout
|
||||
.and not_to_output.to_stderr
|
||||
.and be_a_success
|
||||
|
||||
@ -10,7 +10,7 @@ end
|
||||
describe "brew --cellar", :integration_test do
|
||||
it "returns the Cellar subdirectory for a given Formula" do
|
||||
expect { brew "--cellar", testball }
|
||||
.to output(%r{#{HOMEBREW_CELLAR}/testball}).to_stdout
|
||||
.to output(%r{#{HOMEBREW_CELLAR}/testball}o).to_stdout
|
||||
.and not_to_output.to_stderr
|
||||
.and be_a_success
|
||||
end
|
||||
|
||||
@ -10,7 +10,7 @@ end
|
||||
describe "brew --prefix", :integration_test do
|
||||
it "prints a given Formula's prefix" do
|
||||
expect { brew "--prefix", testball }
|
||||
.to output(%r{#{HOMEBREW_CELLAR}/testball}).to_stdout
|
||||
.to output(%r{#{HOMEBREW_CELLAR}/testball}o).to_stdout
|
||||
.and not_to_output.to_stderr
|
||||
.and be_a_success
|
||||
end
|
||||
|
||||
@ -10,7 +10,7 @@ end
|
||||
describe "brew --version", :integration_test do
|
||||
it "prints the Homebrew version" do
|
||||
expect { brew "--version" }
|
||||
.to output(/^Homebrew #{Regexp.escape(HOMEBREW_VERSION)}\n/).to_stdout
|
||||
.to output(/^Homebrew #{Regexp.escape(HOMEBREW_VERSION)}\n/o).to_stdout
|
||||
.and not_to_output.to_stderr
|
||||
.and be_a_success
|
||||
end
|
||||
|
||||
@ -22,7 +22,7 @@ describe "brew cleanup", :integration_test do
|
||||
(HOMEBREW_CACHE/"test").write "test"
|
||||
|
||||
expect { brew "cleanup", "--prune=all" }
|
||||
.to output(%r{#{Regexp.escape(HOMEBREW_CACHE)}/test}).to_stdout
|
||||
.to output(%r{#{Regexp.escape(HOMEBREW_CACHE)}/test}o).to_stdout
|
||||
.and not_to_output.to_stderr
|
||||
.and be_a_success
|
||||
end
|
||||
|
||||
@ -10,7 +10,7 @@ end
|
||||
describe "brew config", :integration_test do
|
||||
it "prints information about the current Homebrew configuration" do
|
||||
expect { brew "config" }
|
||||
.to output(/HOMEBREW_VERSION: #{Regexp.escape HOMEBREW_VERSION}/).to_stdout
|
||||
.to output(/HOMEBREW_VERSION: #{Regexp.escape HOMEBREW_VERSION}/o).to_stdout
|
||||
.and not_to_output.to_stderr
|
||||
.and be_a_success
|
||||
end
|
||||
|
||||
@ -12,7 +12,7 @@ describe "brew install", :integration_test do
|
||||
setup_test_formula "testball1"
|
||||
|
||||
expect { brew "install", "testball1" }
|
||||
.to output(%r{#{HOMEBREW_CELLAR}/testball1/0\.1}).to_stdout
|
||||
.to output(%r{#{HOMEBREW_CELLAR}/testball1/0\.1}o).to_stdout
|
||||
.and not_to_output.to_stderr
|
||||
.and be_a_success
|
||||
expect(HOMEBREW_CELLAR/"testball1/0.1/foo/test").not_to be_a_file
|
||||
@ -22,7 +22,7 @@ describe "brew install", :integration_test do
|
||||
setup_test_formula "testball1"
|
||||
|
||||
expect { brew "install", "testball1", "--with-foo" }
|
||||
.to output(%r{#{HOMEBREW_CELLAR}/testball1/0\.1}).to_stdout
|
||||
.to output(%r{#{HOMEBREW_CELLAR}/testball1/0\.1}o).to_stdout
|
||||
.and not_to_output.to_stderr
|
||||
.and be_a_success
|
||||
expect(HOMEBREW_CELLAR/"testball1/0.1/foo/test").to be_a_file
|
||||
@ -36,7 +36,7 @@ describe "brew install", :integration_test do
|
||||
RUBY
|
||||
|
||||
expect { brew "install", "testball1" }
|
||||
.to output(%r{#{HOMEBREW_CELLAR}/testball1/1\.0}).to_stdout
|
||||
.to output(%r{#{HOMEBREW_CELLAR}/testball1/1\.0}o).to_stdout
|
||||
.and not_to_output.to_stderr
|
||||
.and be_a_success
|
||||
expect(HOMEBREW_CELLAR/"testball1/1.0/foo/test").not_to be_a_file
|
||||
@ -69,7 +69,7 @@ describe "brew install", :integration_test do
|
||||
# and there will be the git requirement, but we cannot instantiate git
|
||||
# formula since we only have testball1 formula.
|
||||
expect { brew "install", "testball1", "--HEAD", "--ignore-dependencies" }
|
||||
.to output(%r{#{HOMEBREW_CELLAR}/testball1/HEAD-d5eb689}).to_stdout
|
||||
.to output(%r{#{HOMEBREW_CELLAR}/testball1/HEAD-d5eb689}o).to_stdout
|
||||
.and output(/Cloning into/).to_stderr
|
||||
.and be_a_success
|
||||
expect(HOMEBREW_CELLAR/"testball1/HEAD-d5eb689/foo/test").not_to be_a_file
|
||||
|
||||
@ -10,7 +10,7 @@ end
|
||||
describe "brew command", :integration_test do
|
||||
it "returns the file for a given command" do
|
||||
expect { brew "command", "info" }
|
||||
.to output(%r{#{Regexp.escape(HOMEBREW_LIBRARY_PATH)}/cmd/info.rb}).to_stdout
|
||||
.to output(%r{#{Regexp.escape(HOMEBREW_LIBRARY_PATH)}/cmd/info.rb}o).to_stdout
|
||||
.and be_a_success
|
||||
end
|
||||
end
|
||||
|
||||
@ -66,7 +66,7 @@ describe Homebrew::Diagnostic::Checks do
|
||||
|
||||
specify "#check_user_path_2" do
|
||||
ENV["PATH"] = ENV["PATH"].gsub \
|
||||
%r{(?:^|#{File::PATH_SEPARATOR})#{HOMEBREW_PREFIX}/bin}, ""
|
||||
%r{(?:^|#{File::PATH_SEPARATOR})#{HOMEBREW_PREFIX}/bin}o, ""
|
||||
|
||||
expect(subject.check_user_path_1).to be nil
|
||||
expect(subject.check_user_path_2)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user