diff --git a/Library/.rubocop.yml b/Library/.rubocop.yml index 351a9f71b7..48b7093d10 100644 --- a/Library/.rubocop.yml +++ b/Library/.rubocop.yml @@ -37,10 +37,6 @@ Layout/EndAlignment: Layout/SpaceAroundOperators: 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) # and layout is not configurable (https://github.com/rubocop-hq/rubocop/issues/6254). Layout/RescueEnsureAlignment: diff --git a/Library/Homebrew/cache_store.rb b/Library/Homebrew/cache_store.rb index aaaeb8604c..9aeac80ee4 100644 --- a/Library/Homebrew/cache_store.rb +++ b/Library/Homebrew/cache_store.rb @@ -39,6 +39,7 @@ class CacheStoreDatabase # Closes the underlying database (if it is created and open). def close_if_open! return unless @db + cache_path.dirname.mkpath cache_path.atomic_write(JSON.dump(@db)) end @@ -55,6 +56,7 @@ class CacheStoreDatabase # @return [Time] def mtime return unless created? + cache_path.mtime end diff --git a/Library/Homebrew/cask/artifact/abstract_uninstall.rb b/Library/Homebrew/cask/artifact/abstract_uninstall.rb index 7bef09818a..47e3d6cded 100644 --- a/Library/Homebrew/cask/artifact/abstract_uninstall.rb +++ b/Library/Homebrew/cask/artifact/abstract_uninstall.rb @@ -136,6 +136,7 @@ module Cask Timeout.timeout(10) do Kernel.loop do next unless quit(bundle_id).success? + if running_processes(bundle_id).empty? puts "Application '#{bundle_id}' quit successfully." break diff --git a/Library/Homebrew/cask/audit.rb b/Library/Homebrew/cask/audit.rb index 77186462dc..6e73ccf16f 100644 --- a/Library/Homebrew/cask/audit.rb +++ b/Library/Homebrew/cask/audit.rb @@ -292,6 +292,7 @@ module Cask def check_https_availability return unless download + if !cask.url.blank? && !cask.url.using check_url_for_https_availability(cask.url, user_agents: [cask.url.user_agent]) end diff --git a/Library/Homebrew/cask/cmd/automerge.rb b/Library/Homebrew/cask/cmd/automerge.rb index b71083bac6..c830744ff1 100755 --- a/Library/Homebrew/cask/cmd/automerge.rb +++ b/Library/Homebrew/cask/cmd/automerge.rb @@ -63,6 +63,7 @@ module Cask end return if failed.empty? + $stderr.puts raise CaskError, "Failed merging the following PRs:\n#{failed.join("\n")}" end @@ -90,8 +91,10 @@ module Cask def diff_is_single_cask(diff) return false unless diff.files.count == 1 + file = diff.files.first return false unless file.a_path == file.b_path + file.a_path.match?(%r{\ACasks/[^/]+\.rb\Z}) end diff --git a/Library/Homebrew/cleanup.rb b/Library/Homebrew/cleanup.rb index 4a0691989e..0cbec1c7fe 100644 --- a/Library/Homebrew/cleanup.rb +++ b/Library/Homebrew/cleanup.rb @@ -203,6 +203,7 @@ module Homebrew # avoid having to try to do a `brew install` when we've just deleted # the running Ruby process... return if periodic + cleanup_portable_ruby else args.each do |arg| @@ -251,6 +252,7 @@ module Homebrew def cleanup_logs return unless HOMEBREW_LOGS.directory? + logs_days = if days > CLEANUP_DEFAULT_DAYS CLEANUP_DEFAULT_DAYS else @@ -364,6 +366,7 @@ module Homebrew portable_ruby_glob = "#{portable_ruby_path}/*.*" Pathname.glob(portable_ruby_glob).each do |path| next if !use_system_ruby && portable_ruby_version == path.basename.to_s + if dry_run? puts "Would remove: #{path} (#{path.abv})" else diff --git a/Library/Homebrew/cli_parser.rb b/Library/Homebrew/cli_parser.rb index 963111528e..79ed8b299c 100644 --- a/Library/Homebrew/cli_parser.rb +++ b/Library/Homebrew/cli_parser.rb @@ -154,6 +154,7 @@ module Homebrew def formula_options ARGV.formulae.each do |f| next if f.options.empty? + f.options.each do |o| name = o.flag description = "`#{f.name}`: #{o.description}" @@ -238,6 +239,7 @@ module Homebrew select_cli_arg = violations.count - env_var_options.count == 1 raise OptionConflictError, violations.map(&method(:name_to_option)) unless select_cli_arg + env_var_options.each(&method(:disable_switch)) end end diff --git a/Library/Homebrew/cmd/config.rb b/Library/Homebrew/cmd/config.rb index 492a6d47a8..e687aa281c 100644 --- a/Library/Homebrew/cmd/config.rb +++ b/Library/Homebrew/cmd/config.rb @@ -21,6 +21,7 @@ module Homebrew def config config_args.parse raise UsageError unless args.remaining.empty? + SystemConfig.dump_verbose_config end end diff --git a/Library/Homebrew/cmd/info.rb b/Library/Homebrew/cmd/info.rb index 6e834a94c8..b2cd428977 100644 --- a/Library/Homebrew/cmd/info.rb +++ b/Library/Homebrew/cmd/info.rb @@ -51,6 +51,7 @@ module Homebrew info_args.parse if args.json raise UsageError, "invalid JSON version: #{args.json}" unless ["v1", true].include? args.json + print_json elsif args.github? exec_browser(*ARGV.formulae.map { |f| github_info(f) }) diff --git a/Library/Homebrew/config.rb b/Library/Homebrew/config.rb index 098177aff6..0e4642c953 100644 --- a/Library/Homebrew/config.rb +++ b/Library/Homebrew/config.rb @@ -7,6 +7,7 @@ class MissingEnvironmentVariables < RuntimeError; end def get_env_or_raise(env) raise MissingEnvironmentVariables, "#{env} was not exported!" unless ENV[env] + ENV[env] end diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb index 96d23902af..0efd28627f 100644 --- a/Library/Homebrew/dev-cmd/audit.rb +++ b/Library/Homebrew/dev-cmd/audit.rb @@ -556,6 +556,7 @@ module Homebrew problem "Unrecognized bottle modifier" unless formula.bottle_disable_reason.valid? return unless @core_tap + problem "Formulae should not use `bottle :disabled`" end @@ -884,6 +885,7 @@ module Homebrew return unless @core_tap return unless line.include?("env :std") + problem "`env :std` in `core` formulae is deprecated" end diff --git a/Library/Homebrew/dev-cmd/bump-formula-pr.rb b/Library/Homebrew/dev-cmd/bump-formula-pr.rb index 205a2cd0e8..36c177897f 100644 --- a/Library/Homebrew/dev-cmd/bump-formula-pr.rb +++ b/Library/Homebrew/dev-cmd/bump-formula-pr.rb @@ -331,6 +331,7 @@ module Homebrew username = response.fetch("owner").fetch("login") rescue GitHub::AuthenticationFailedError => e raise unless e.github_message =~ /forking is disabled/ + # If the repository is private, forking might be disabled. # Create branches in the repository itself instead. remote_url = Utils.popen_read("git remote get-url --push origin").chomp diff --git a/Library/Homebrew/dev-cmd/man.rb b/Library/Homebrew/dev-cmd/man.rb index 15b84672d6..b58849b99a 100644 --- a/Library/Homebrew/dev-cmd/man.rb +++ b/Library/Homebrew/dev-cmd/man.rb @@ -155,9 +155,11 @@ module Homebrew cmd_man_page_lines = begin cmd_parser = Homebrew.send(cmd_args_method_name) next if cmd_parser.hide_from_man_page + cmd_parser_manpage_lines(cmd_parser).join rescue NoMethodError => e raise if e.name != cmd_args_method_name + nil end 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 += cmd_parser.processed_options.map do |short, long, _, desc| next if !long.nil? && cmd_parser.global_option?(cmd_parser.option_to_name(long)) + generate_option_doc(short, long, desc) end.reject(&:blank?) lines @@ -185,11 +188,13 @@ module Homebrew comment_lines = cmd_path.read.lines.grep(/^#:/) return if comment_lines.empty? return if comment_lines.first.include?("@hide_from_man_page") + lines = [format_usage_banner(comment_lines.first).chomp] comment_lines.slice(1..-1) .each do |line| line = line.slice(4..-1) next unless line + lines << line.gsub(/^ +(-+[a-z-]+) */, "* `\\1`:\n ") end lines diff --git a/Library/Homebrew/extend/os/linux/dependency_collector.rb b/Library/Homebrew/extend/os/linux/dependency_collector.rb index a983b3cb4a..1949002cc3 100644 --- a/Library/Homebrew/extend/os/linux/dependency_collector.rb +++ b/Library/Homebrew/extend/os/linux/dependency_collector.rb @@ -5,6 +5,7 @@ class DependencyCollector dep = Dependency.new("openjdk", tags) return dep if dep.installed? return req if req.satisfied? + dep rescue FormulaUnavailableError req diff --git a/Library/Homebrew/extend/os/mac/diagnostic.rb b/Library/Homebrew/extend/os/mac/diagnostic.rb index 601db6e05f..32ad1ffd54 100644 --- a/Library/Homebrew/extend/os/mac/diagnostic.rb +++ b/Library/Homebrew/extend/os/mac/diagnostic.rb @@ -106,6 +106,7 @@ module Homebrew def check_xcode_minimum_version return unless MacOS::Xcode.below_minimum_version? + xcode = MacOS::Xcode.version.to_s xcode += " => #{MacOS::Xcode.prefix}" unless MacOS::Xcode.default_prefix? diff --git a/Library/Homebrew/help.rb b/Library/Homebrew/help.rb index 6b734c3b70..9a7ecd9020 100644 --- a/Library/Homebrew/help.rb +++ b/Library/Homebrew/help.rb @@ -83,6 +83,7 @@ module Homebrew .generate_help_text rescue NoMethodError => e raise if e.name != cmd_args_method_name + nil end diff --git a/Library/Homebrew/language/java.rb b/Library/Homebrew/language/java.rb index 3dc8d18d23..01ff28d9eb 100644 --- a/Library/Homebrew/language/java.rb +++ b/Library/Homebrew/language/java.rb @@ -8,6 +8,7 @@ module Language def self.java_home(version = nil) req = JavaRequirement.new [*version] raise UnsatisfiedRequirements, req.message unless req.satisfied? + req.java_home end diff --git a/Library/Homebrew/os/mac/xcode.rb b/Library/Homebrew/os/mac/xcode.rb index 7d1742e3ce..97a448b84e 100644 --- a/Library/Homebrew/os/mac/xcode.rb +++ b/Library/Homebrew/os/mac/xcode.rb @@ -310,6 +310,7 @@ module OS version = nil [EXECUTABLE_PKG_ID, MAVERICKS_NEW_PKG_ID].each do |id| next unless File.exist?("#{PKG_PATH}/usr/bin/clang") + version = MacOS.pkgutil_info(id)[/version: (.+)$/, 1] break if version end diff --git a/Library/Homebrew/system_command.rb b/Library/Homebrew/system_command.rb index 2b1c222fe8..fe2ca7dc46 100644 --- a/Library/Homebrew/system_command.rb +++ b/Library/Homebrew/system_command.rb @@ -197,6 +197,7 @@ class SystemCommand def success? return false if @exit_status.nil? + @exit_status.zero? end diff --git a/Library/Homebrew/test/support/helper/spec/shared_context/integration_test.rb b/Library/Homebrew/test/support/helper/spec/shared_context/integration_test.rb index aceb130b14..cf8c939d55 100644 --- a/Library/Homebrew/test/support/helper/spec/shared_context/integration_test.rb +++ b/Library/Homebrew/test/support/helper/spec/shared_context/integration_test.rb @@ -176,6 +176,7 @@ RSpec.shared_context "integration test" do def setup_remote_tap(name) Tap.fetch(name).tap do |tap| next if tap.installed? + full_name = Tap.fetch(name).full_name # Check to see if the original Homebrew process has taps we can use. system_tap_path = Pathname("#{ENV["HOMEBREW_LIBRARY"]}/Taps/#{full_name}") diff --git a/Library/Homebrew/utils/user.rb b/Library/Homebrew/utils/user.rb index d8658d49dc..e572a0a8ee 100644 --- a/Library/Homebrew/utils/user.rb +++ b/Library/Homebrew/utils/user.rb @@ -7,6 +7,7 @@ class User < DelegateClass(String) def gui? out, _, status = system_command "who" return false unless status.success? + out.lines .map(&:split) .any? { |user, type,| user == self && type == "console" }