Class: Homebrew::Cmd::Doctor Private

Inherits:
AbstractCommand show all
Defined in:
cmd/doctor.rb,
sorbet/rbi/dsl/homebrew/cmd/doctor.rbi

This class is part of a private API. This class may only be used in the Homebrew/brew repository. Third parties should avoid using this class if possible, as it may be removed or changed without warning.

Defined Under Namespace

Classes: Args

Instance Method Summary collapse

Methods inherited from AbstractCommand

command, command_name, dev_cmd?, #initialize, parser, ruby_cmd?

Methods included from Utils::Output::Mixin

#issue_reporting_message, #odebug, #odeprecated, #odie, #odisabled, #ofail, #oh1, #oh1_title, #ohai, #ohai_title, #onoe, #opoo, #opoo_outside_github_actions, #opoo_without_github_actions_annotation, #pretty_deprecated, #pretty_disabled, #pretty_duration, #pretty_install_status, #pretty_installed, #pretty_uninstalled, #pretty_unmarked, #pretty_upgradable, #pretty_warning

Constructor Details

This class inherits a constructor from Homebrew::AbstractCommand

Instance Method Details

#argsHomebrew::Cmd::Doctor::Args

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.



10
# File 'sorbet/rbi/dsl/homebrew/cmd/doctor.rbi', line 10

def args; end

#runvoid

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

This method returns an undefined value.



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'cmd/doctor.rb', line 35

def run
  Homebrew.inject_dump_stats!(Diagnostic::Checks, /^check_*/) if args.audit_debug?

  checks = Diagnostic::Checks.new(verbose: args.verbose?)

  if args.list_checks?
    puts checks.all
    return
  end

  if args.no_named?
    slow_checks = %w[
      check_for_broken_symlinks
      check_missing_deps
    ]
    methods = (checks.all - slow_checks) + slow_checks
    methods -= checks.cask_checks unless Cask::Caskroom.any_casks_installed?
  else
    methods = args.named
  end

  finding_collection = []
  first_warning = T.let(true, T::Boolean)
  methods.each do |method|
    $stderr.puts Formatter.headline("Checking #{method}", color: :magenta) if args.debug?
    unless checks.respond_to?(method)
      ofail "No check available by the name: #{method}"
      next
    end

    finding         = checks.public_send(method)
    method_findings = T.let(Array(finding).compact, T::Array[T.any(Diagnostic::Finding, String)])
    next if method_findings.empty?

    finding_collection.concat(method_findings.compact)
    Homebrew.failed = true
    next if args.json?

    if first_warning && !args.quiet?
      $stderr.puts <<~EOS
        #{Tty.bold}Please note that these warnings are just used to help the Homebrew maintainers
        with debugging if you file an issue. If everything you use Homebrew for is
        working fine: please don't worry or file an issue; just ignore this. Thanks!#{Tty.reset}
      EOS
    end

    $stderr.puts
    opoo method_findings.each(&:to_s).join("\n")
    first_warning = false
  end

  # TODO: Remove string filtering when all diagnostics are Finding objects
  finding_maps = finding_collection.grep_v(String).map(&:to_h)
  tier = (finding_maps.max_by { |f| f[:tier] } || {}).fetch(:tier, 1)
  if args.json?
    puts JSON.pretty_generate({ tier:, findings: finding_maps }).gsub(/\[\n\n\s*\]/, "[]")

    return
  end

  return if args.quiet?

  if Homebrew.failed?
    puts Diagnostic::Finding.support_tier_message(tier:)
  else
    puts "Your system is ready to brew."
  end
end