rubocop: enable Layout/EmptyLineAfterGuardClause.

This commit is contained in:
Mike McQuaid 2019-02-19 13:12:52 +00:00
parent d64429a736
commit e095da4d01
No known key found for this signature in database
GPG Key ID: 48A898132FD8EE70
21 changed files with 31 additions and 4 deletions

View File

@ -37,10 +37,6 @@ Layout/EndAlignment:
Layout/SpaceAroundOperators: Layout/SpaceAroundOperators:
Enabled: false Enabled: false
# Auto-correct is broken (https://github.com/rubocop-hq/rubocop/issues/6300).
Layout/EmptyLineAfterGuardClause:
Enabled: false
# Auto-correct is broken (https://github.com/rubocop-hq/rubocop/issues/6258) # Auto-correct is broken (https://github.com/rubocop-hq/rubocop/issues/6258)
# and layout is not configurable (https://github.com/rubocop-hq/rubocop/issues/6254). # and layout is not configurable (https://github.com/rubocop-hq/rubocop/issues/6254).
Layout/RescueEnsureAlignment: Layout/RescueEnsureAlignment:

View File

@ -39,6 +39,7 @@ class CacheStoreDatabase
# Closes the underlying database (if it is created and open). # Closes the underlying database (if it is created and open).
def close_if_open! def close_if_open!
return unless @db return unless @db
cache_path.dirname.mkpath cache_path.dirname.mkpath
cache_path.atomic_write(JSON.dump(@db)) cache_path.atomic_write(JSON.dump(@db))
end end
@ -55,6 +56,7 @@ class CacheStoreDatabase
# @return [Time] # @return [Time]
def mtime def mtime
return unless created? return unless created?
cache_path.mtime cache_path.mtime
end end

View File

@ -136,6 +136,7 @@ module Cask
Timeout.timeout(10) do Timeout.timeout(10) do
Kernel.loop do Kernel.loop do
next unless quit(bundle_id).success? next unless quit(bundle_id).success?
if running_processes(bundle_id).empty? if running_processes(bundle_id).empty?
puts "Application '#{bundle_id}' quit successfully." puts "Application '#{bundle_id}' quit successfully."
break break

View File

@ -292,6 +292,7 @@ module Cask
def check_https_availability def check_https_availability
return unless download return unless download
if !cask.url.blank? && !cask.url.using if !cask.url.blank? && !cask.url.using
check_url_for_https_availability(cask.url, user_agents: [cask.url.user_agent]) check_url_for_https_availability(cask.url, user_agents: [cask.url.user_agent])
end end

View File

@ -63,6 +63,7 @@ module Cask
end end
return if failed.empty? return if failed.empty?
$stderr.puts $stderr.puts
raise CaskError, "Failed merging the following PRs:\n#{failed.join("\n")}" raise CaskError, "Failed merging the following PRs:\n#{failed.join("\n")}"
end end
@ -90,8 +91,10 @@ module Cask
def diff_is_single_cask(diff) def diff_is_single_cask(diff)
return false unless diff.files.count == 1 return false unless diff.files.count == 1
file = diff.files.first file = diff.files.first
return false unless file.a_path == file.b_path return false unless file.a_path == file.b_path
file.a_path.match?(%r{\ACasks/[^/]+\.rb\Z}) file.a_path.match?(%r{\ACasks/[^/]+\.rb\Z})
end end

View File

@ -203,6 +203,7 @@ module Homebrew
# avoid having to try to do a `brew install` when we've just deleted # avoid having to try to do a `brew install` when we've just deleted
# the running Ruby process... # the running Ruby process...
return if periodic return if periodic
cleanup_portable_ruby cleanup_portable_ruby
else else
args.each do |arg| args.each do |arg|
@ -251,6 +252,7 @@ module Homebrew
def cleanup_logs def cleanup_logs
return unless HOMEBREW_LOGS.directory? return unless HOMEBREW_LOGS.directory?
logs_days = if days > CLEANUP_DEFAULT_DAYS logs_days = if days > CLEANUP_DEFAULT_DAYS
CLEANUP_DEFAULT_DAYS CLEANUP_DEFAULT_DAYS
else else
@ -364,6 +366,7 @@ module Homebrew
portable_ruby_glob = "#{portable_ruby_path}/*.*" portable_ruby_glob = "#{portable_ruby_path}/*.*"
Pathname.glob(portable_ruby_glob).each do |path| Pathname.glob(portable_ruby_glob).each do |path|
next if !use_system_ruby && portable_ruby_version == path.basename.to_s next if !use_system_ruby && portable_ruby_version == path.basename.to_s
if dry_run? if dry_run?
puts "Would remove: #{path} (#{path.abv})" puts "Would remove: #{path} (#{path.abv})"
else else

View File

@ -154,6 +154,7 @@ module Homebrew
def formula_options def formula_options
ARGV.formulae.each do |f| ARGV.formulae.each do |f|
next if f.options.empty? next if f.options.empty?
f.options.each do |o| f.options.each do |o|
name = o.flag name = o.flag
description = "`#{f.name}`: #{o.description}" description = "`#{f.name}`: #{o.description}"
@ -238,6 +239,7 @@ module Homebrew
select_cli_arg = violations.count - env_var_options.count == 1 select_cli_arg = violations.count - env_var_options.count == 1
raise OptionConflictError, violations.map(&method(:name_to_option)) unless select_cli_arg raise OptionConflictError, violations.map(&method(:name_to_option)) unless select_cli_arg
env_var_options.each(&method(:disable_switch)) env_var_options.each(&method(:disable_switch))
end end
end end

View File

@ -21,6 +21,7 @@ module Homebrew
def config def config
config_args.parse config_args.parse
raise UsageError unless args.remaining.empty? raise UsageError unless args.remaining.empty?
SystemConfig.dump_verbose_config SystemConfig.dump_verbose_config
end end
end end

View File

@ -51,6 +51,7 @@ module Homebrew
info_args.parse info_args.parse
if args.json if args.json
raise UsageError, "invalid JSON version: #{args.json}" unless ["v1", true].include? args.json raise UsageError, "invalid JSON version: #{args.json}" unless ["v1", true].include? args.json
print_json print_json
elsif args.github? elsif args.github?
exec_browser(*ARGV.formulae.map { |f| github_info(f) }) exec_browser(*ARGV.formulae.map { |f| github_info(f) })

View File

@ -7,6 +7,7 @@ class MissingEnvironmentVariables < RuntimeError; end
def get_env_or_raise(env) def get_env_or_raise(env)
raise MissingEnvironmentVariables, "#{env} was not exported!" unless ENV[env] raise MissingEnvironmentVariables, "#{env} was not exported!" unless ENV[env]
ENV[env] ENV[env]
end end

View File

@ -556,6 +556,7 @@ module Homebrew
problem "Unrecognized bottle modifier" unless formula.bottle_disable_reason.valid? problem "Unrecognized bottle modifier" unless formula.bottle_disable_reason.valid?
return unless @core_tap return unless @core_tap
problem "Formulae should not use `bottle :disabled`" problem "Formulae should not use `bottle :disabled`"
end end
@ -884,6 +885,7 @@ module Homebrew
return unless @core_tap return unless @core_tap
return unless line.include?("env :std") return unless line.include?("env :std")
problem "`env :std` in `core` formulae is deprecated" problem "`env :std` in `core` formulae is deprecated"
end end

View File

@ -331,6 +331,7 @@ module Homebrew
username = response.fetch("owner").fetch("login") username = response.fetch("owner").fetch("login")
rescue GitHub::AuthenticationFailedError => e rescue GitHub::AuthenticationFailedError => e
raise unless e.github_message =~ /forking is disabled/ raise unless e.github_message =~ /forking is disabled/
# If the repository is private, forking might be disabled. # If the repository is private, forking might be disabled.
# Create branches in the repository itself instead. # Create branches in the repository itself instead.
remote_url = Utils.popen_read("git remote get-url --push origin").chomp remote_url = Utils.popen_read("git remote get-url --push origin").chomp

View File

@ -155,9 +155,11 @@ module Homebrew
cmd_man_page_lines = begin cmd_man_page_lines = begin
cmd_parser = Homebrew.send(cmd_args_method_name) cmd_parser = Homebrew.send(cmd_args_method_name)
next if cmd_parser.hide_from_man_page next if cmd_parser.hide_from_man_page
cmd_parser_manpage_lines(cmd_parser).join cmd_parser_manpage_lines(cmd_parser).join
rescue NoMethodError => e rescue NoMethodError => e
raise if e.name != cmd_args_method_name raise if e.name != cmd_args_method_name
nil nil
end end
cmd_man_page_lines ||= cmd_comment_manpage_lines(cmd_path) cmd_man_page_lines ||= cmd_comment_manpage_lines(cmd_path)
@ -176,6 +178,7 @@ module Homebrew
lines = [format_usage_banner(cmd_parser.usage_banner_text)] lines = [format_usage_banner(cmd_parser.usage_banner_text)]
lines += cmd_parser.processed_options.map do |short, long, _, desc| lines += cmd_parser.processed_options.map do |short, long, _, desc|
next if !long.nil? && cmd_parser.global_option?(cmd_parser.option_to_name(long)) next if !long.nil? && cmd_parser.global_option?(cmd_parser.option_to_name(long))
generate_option_doc(short, long, desc) generate_option_doc(short, long, desc)
end.reject(&:blank?) end.reject(&:blank?)
lines lines
@ -185,11 +188,13 @@ module Homebrew
comment_lines = cmd_path.read.lines.grep(/^#:/) comment_lines = cmd_path.read.lines.grep(/^#:/)
return if comment_lines.empty? return if comment_lines.empty?
return if comment_lines.first.include?("@hide_from_man_page") return if comment_lines.first.include?("@hide_from_man_page")
lines = [format_usage_banner(comment_lines.first).chomp] lines = [format_usage_banner(comment_lines.first).chomp]
comment_lines.slice(1..-1) comment_lines.slice(1..-1)
.each do |line| .each do |line|
line = line.slice(4..-1) line = line.slice(4..-1)
next unless line next unless line
lines << line.gsub(/^ +(-+[a-z-]+) */, "* `\\1`:\n ") lines << line.gsub(/^ +(-+[a-z-]+) */, "* `\\1`:\n ")
end end
lines lines

View File

@ -5,6 +5,7 @@ class DependencyCollector
dep = Dependency.new("openjdk", tags) dep = Dependency.new("openjdk", tags)
return dep if dep.installed? return dep if dep.installed?
return req if req.satisfied? return req if req.satisfied?
dep dep
rescue FormulaUnavailableError rescue FormulaUnavailableError
req req

View File

@ -106,6 +106,7 @@ module Homebrew
def check_xcode_minimum_version def check_xcode_minimum_version
return unless MacOS::Xcode.below_minimum_version? return unless MacOS::Xcode.below_minimum_version?
xcode = MacOS::Xcode.version.to_s xcode = MacOS::Xcode.version.to_s
xcode += " => #{MacOS::Xcode.prefix}" unless MacOS::Xcode.default_prefix? xcode += " => #{MacOS::Xcode.prefix}" unless MacOS::Xcode.default_prefix?

View File

@ -83,6 +83,7 @@ module Homebrew
.generate_help_text .generate_help_text
rescue NoMethodError => e rescue NoMethodError => e
raise if e.name != cmd_args_method_name raise if e.name != cmd_args_method_name
nil nil
end end

View File

@ -8,6 +8,7 @@ module Language
def self.java_home(version = nil) def self.java_home(version = nil)
req = JavaRequirement.new [*version] req = JavaRequirement.new [*version]
raise UnsatisfiedRequirements, req.message unless req.satisfied? raise UnsatisfiedRequirements, req.message unless req.satisfied?
req.java_home req.java_home
end end

View File

@ -310,6 +310,7 @@ module OS
version = nil version = nil
[EXECUTABLE_PKG_ID, MAVERICKS_NEW_PKG_ID].each do |id| [EXECUTABLE_PKG_ID, MAVERICKS_NEW_PKG_ID].each do |id|
next unless File.exist?("#{PKG_PATH}/usr/bin/clang") next unless File.exist?("#{PKG_PATH}/usr/bin/clang")
version = MacOS.pkgutil_info(id)[/version: (.+)$/, 1] version = MacOS.pkgutil_info(id)[/version: (.+)$/, 1]
break if version break if version
end end

View File

@ -197,6 +197,7 @@ class SystemCommand
def success? def success?
return false if @exit_status.nil? return false if @exit_status.nil?
@exit_status.zero? @exit_status.zero?
end end

View File

@ -176,6 +176,7 @@ RSpec.shared_context "integration test" do
def setup_remote_tap(name) def setup_remote_tap(name)
Tap.fetch(name).tap do |tap| Tap.fetch(name).tap do |tap|
next if tap.installed? next if tap.installed?
full_name = Tap.fetch(name).full_name full_name = Tap.fetch(name).full_name
# Check to see if the original Homebrew process has taps we can use. # Check to see if the original Homebrew process has taps we can use.
system_tap_path = Pathname("#{ENV["HOMEBREW_LIBRARY"]}/Taps/#{full_name}") system_tap_path = Pathname("#{ENV["HOMEBREW_LIBRARY"]}/Taps/#{full_name}")

View File

@ -7,6 +7,7 @@ class User < DelegateClass(String)
def gui? def gui?
out, _, status = system_command "who" out, _, status = system_command "who"
return false unless status.success? return false unless status.success?
out.lines out.lines
.map(&:split) .map(&:split)
.any? { |user, type,| user == self && type == "console" } .any? { |user, type,| user == self && type == "console" }