Class: SecureKeys::Validation::ValidationIssue

Inherits:
Object
  • Object
show all
Defined in:
lib/validation/validation_issue.rb

Overview

Represents a single issue detected during secret validation

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(severity:, type:, message:, recommendation:) ⇒ ValidationIssue

Initialize a new validation issue

Parameters:

  • severity (Symbol)

    The severity level (:critical, :error, :warning, :info)

  • type (Symbol)

    The category of the issue (e.g. :empty_value, :weak_secret)

  • message (String)

    A human-readable description of the issue

  • recommendation (String, nil)

    An optional actionable recommendation for the developer



14
15
16
17
18
19
# File 'lib/validation/validation_issue.rb', line 14

def initialize(severity:, type:, message:, recommendation:)
  @severity = severity
  @type = type
  @message = message
  @recommendation = recommendation
end

Instance Attribute Details

#messageObject (readonly)

Returns the value of attribute message.



7
8
9
# File 'lib/validation/validation_issue.rb', line 7

def message
  @message
end

#recommendationObject (readonly)

Returns the value of attribute recommendation.



7
8
9
# File 'lib/validation/validation_issue.rb', line 7

def recommendation
  @recommendation
end

#severityObject (readonly)

Returns the value of attribute severity.



7
8
9
# File 'lib/validation/validation_issue.rb', line 7

def severity
  @severity
end

#typeObject (readonly)

Returns the value of attribute type.



7
8
9
# File 'lib/validation/validation_issue.rb', line 7

def type
  @type
end

Instance Method Details

#to_hHash

Returns a hash representation of the issue

Returns:

  • (Hash)

    The hash representation



31
32
33
34
35
36
37
38
# File 'lib/validation/validation_issue.rb', line 31

def to_h
  {
    severity:,
    type:,
    message:,
    recommendation:,
  }
end

#to_sString

Returns a string representation of the issue, including the recommendation if present

Returns:

  • (String)

    The formatted issue string



23
24
25
26
27
# File 'lib/validation/validation_issue.rb', line 23

def to_s
  text = "#{severity_icon} #{severity.upcase}: #{message}"
  text += "\n\t\t💡 #{recommendation}" if recommendation
  text
end