Class: Homebrew::Diagnostic::Finding Private

Inherits:
Object
  • Object
show all
Defined in:
diagnostic/finding.rb

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: Remediation

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(text, tier: 1, affects: [], links: [], remediation: nil) ⇒ 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.

Parameters:



52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'diagnostic/finding.rb', line 52

def initialize(text, tier: 1, affects: [], links: [], remediation: nil)
  @text = text
  @tier = tier
  @affects = affects
  @links = links
  @remediation ||= T.let(
    if remediation.is_a?(String)
      Remediation.new(text: remediation)
    else
      remediation
    end,
    T.nilable(Homebrew::Diagnostic::Finding::Remediation),
  )
end

Instance Attribute Details

#affectsArray<String> (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.

Returns:



43
44
45
# File 'diagnostic/finding.rb', line 43

def affects
  @affects
end

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:



46
47
48
# File 'diagnostic/finding.rb', line 46

def links
  @links
end

#remediationRemediation? (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.

Returns:



49
50
51
# File 'diagnostic/finding.rb', line 49

def remediation
  @remediation
end

#textString (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.

Returns:



37
38
39
# File 'diagnostic/finding.rb', line 37

def text
  @text
end

#tierInteger, Symbol (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.

Returns:



40
41
42
# File 'diagnostic/finding.rb', line 40

def tier
  @tier
end

Class Method Details

.support_tier_message(tier:) ⇒ String?

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.

Parameters:

Returns:



90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# File 'diagnostic/finding.rb', line 90

def self.support_tier_message(tier:)
  return if tier.to_s == "1"

  tier_title, tier_slug, tier_issues = if tier.to_s == "unsupported"
    ["Unsupported", "unsupported", "Do not report any issues"]
  else
    ["Tier #{tier}", "tier-#{tier.to_s.downcase}", "You can report issues with Tier #{tier} configurations"]
  end

  tier_issues = "Report issues to the upstream Nix project, not" if OS.nix_managed_homebrew?

  <<~EOS
    This is a #{tier_title} configuration:
      #{Formatter.url("https://docs.brew.sh/Support-Tiers##{tier_slug}")}
    #{Formatter.bold("#{tier_issues} to Homebrew/* repositories!")}
      #{Formatter.url(OS::ISSUES_URL) if defined?(OS::ISSUES_URL)}
    Read the above document before opening any issues or PRs.
  EOS
end

Instance Method Details

#to_hHash{Symbol => Integer, Symbol, String, Array<String>, Hash{Symbol => String, Array<String>}, nil}

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
74
75
76
77
78
79
# File 'diagnostic/finding.rb', line 71

def to_h
  {
    text:,
    tier:,
    affects:,
    links:,
    remediation: @remediation&.to_h,
  }
end