Class: Cask::Audit Private

Inherits:
Object show all
Extended by:
Attrable
Includes:
SystemCommand::Mixin, Utils::Curl
Defined in:
cask/audit.rb,
sorbet/rbi/parlour.rbi

Overview

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.

Audit a cask for various problems.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Attrable

attr_predicate, attr_rw

Methods included from Utils::Curl

clear_path_cache, curl, curl_args, curl_check_http_content, curl_download, curl_executable, curl_headers, curl_http_content_headers_and_checksum, curl_output, curl_path, curl_response_follow_redirections, curl_response_last_location, curl_supports_tls13?, curl_with_workarounds, http_status_ok?, parse_curl_output, url_protected_by_cloudflare?, url_protected_by_incapsula?

Methods included from SystemCommand::Mixin

#system_command, #system_command!

Methods included from Kernel

#disk_usage_readable, #ensure_executable!, #ensure_formula_installed!, #exec_browser, #exec_editor, #ignore_interrupts, #interactive_shell, #number_readable, #odebug, #odeprecated, #odie, #odisabled, #ofail, #oh1, #oh1_title, #ohai, #ohai_title, #onoe, #opoo, #paths, #pretty_duration, #pretty_installed, #pretty_outdated, #pretty_uninstalled, #quiet_system, #redact_secrets, #redirect_stdout, #require?, #safe_system, #tap_and_name_comparison, #truncate_text_to_approximate_size, #which, #which_all, #which_editor, #with_custom_locale, #with_env, #with_homebrew_path

Constructor Details

#initialize(cask, download: nil, quarantine: nil, token_conflicts: nil, online: nil, strict: nil, signing: nil, new_cask: nil, only: [], except: []) ⇒ Audit

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.

Returns a new instance of Audit.



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'cask/audit.rb', line 26

def initialize(
  cask,
  download: nil, quarantine: nil,
  token_conflicts: nil, online: nil, strict: nil, signing: nil,
  new_cask: nil, only: [], except: []
)
  # `new_cask` implies `online`, `token_conflicts`, `strict` and `signing`
  online = new_cask if online.nil?
  strict = new_cask if strict.nil?
  signing = new_cask if signing.nil?
  token_conflicts = new_cask if token_conflicts.nil?

  # `online` and `signing` imply `download`
  download = online || signing if download.nil?

  @cask = cask
  @download = Download.new(cask, quarantine:) if download
  @online = online
  @strict = strict
  @signing = signing
  @new_cask = new_cask
  @token_conflicts = token_conflicts
  @only = only || []
  @except = except || []
end

Instance Attribute Details

#caskObject (readonly)

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.



22
23
24
# File 'cask/audit.rb', line 22

def cask
  @cask
end

#downloadObject (readonly)

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.



22
23
24
# File 'cask/audit.rb', line 22

def download
  @download
end

Instance Method Details

#add_error(message, location: nil, strict_only: false) ⇒ void

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.

Parameters:



92
93
94
95
96
97
# File 'cask/audit.rb', line 92

def add_error(message, location: nil, strict_only: false)
  # Only raise non-critical audits if the user specified `--strict`.
  return if strict_only && !@strict

  errors << ({ message:, location:, corrected: false })
end

#errorsObject

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.



71
72
73
# File 'cask/audit.rb', line 71

def errors
  @errors ||= []
end

#errors?Boolean

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.

Returns:

  • (Boolean)


76
77
78
# File 'cask/audit.rb', line 76

def errors?
  errors.any?
end

#new_cask?Boolean

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.

Returns:

  • (Boolean)


296
# File 'sorbet/rbi/parlour.rbi', line 296

def new_cask?; end

#online?Boolean

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.

Returns:

  • (Boolean)


305
# File 'sorbet/rbi/parlour.rbi', line 305

def online?; end

#resultObject

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.



99
100
101
# File 'cask/audit.rb', line 99

def result
  Formatter.error("failed") if errors?
end

#run!Object

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.



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'cask/audit.rb', line 52

def run!
  only_audits = @only
  except_audits = @except

  private_methods.map(&:to_s).grep(/^audit_/).each do |audit_method_name|
    name = audit_method_name.delete_prefix("audit_")
    next if !only_audits.empty? && only_audits&.exclude?(name)
    next if except_audits&.include?(name)

    send(audit_method_name)
  end

  self
rescue => e
  odebug e, ::Utils::Backtrace.clean(e)
  add_error "exception while auditing #{cask}: #{e.message}"
  self
end

#signing?Boolean

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.

Returns:

  • (Boolean)


302
# File 'sorbet/rbi/parlour.rbi', line 302

def signing?; end

#strict?Boolean

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.

Returns:

  • (Boolean)


299
# File 'sorbet/rbi/parlour.rbi', line 299

def strict?; end

#success?Boolean

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.

Returns:

  • (Boolean)


81
82
83
# File 'cask/audit.rb', line 81

def success?
  !errors?
end

#summaryString?

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.

Returns:



104
105
106
107
108
109
110
111
112
113
114
# File 'cask/audit.rb', line 104

def summary
  return if success?

  summary = ["audit for #{cask}: #{result}"]

  errors.each do |error|
    summary << " #{Formatter.error("-")} #{error[:message]}"
  end

  summary.join("\n")
end

#token_conflicts?Boolean

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.

Returns:

  • (Boolean)


308
# File 'sorbet/rbi/parlour.rbi', line 308

def token_conflicts?; end