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:



54
55
56
57
58
59
60
61
62
# File 'diagnostic/finding.rb', line 54

def initialize(text, tier: 1, affects: [], links: [], remediation: nil)
  @text = text
  @tier = tier
  @affects = affects
  @links = links

  remediation = Remediation.new(text: remediation) if remediation.is_a?(String)
  @remediation = T.let(remediation, T.nilable(Remediation))
end

Instance Attribute Details

#affects ⇒ Array<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:



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

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:



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

def links
  @links
end

#remediation ⇒ Remediation? (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:



51
52
53
# File 'diagnostic/finding.rb', line 51

def remediation
  @remediation
end

#text ⇒ 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:



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

def text
  @text
end

#tier ⇒ Integer, 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:



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

def tier
  @tier
end

Class Method Details

.support_tier(tiers) ⇒ Integer, Symbol

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:



87
88
89
90
91
# File 'diagnostic/finding.rb', line 87

def self.support_tier(tiers)
  return :unsupported if tiers.include?(:unsupported)

  tiers.grep(Integer).max || 1
end

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



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

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

  tier = :unsupported if tier == "unsupported"
  tier = tier.to_i if tier.is_a?(String)
  tier_title, tier_slug = if tier == :unsupported
    ["an Unsupported", "unsupported"]
  else
    ["a Tier #{tier}", "tier-#{tier}"]
  end

  <<~EOS
    This is #{tier_title} configuration:
      #{Formatter.url("https://docs.brew.sh/Support-Tiers##{tier_slug}")}
    #{Utils::Output.issue_reporting_message(:homebrew, tier:)}
  EOS
end

Instance Method Details

#to_h ⇒ Hash{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.

Returns:



68
69
70
71
72
73
74
75
76
# File 'diagnostic/finding.rb', line 68

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