Class: Finding

Inherits:
Struct
  • Object
show all
Defined in:
lib/finding.rb,
lib/finding.rb

Constant Summary collapse

SEVERITIES =
%i[critical high medium low].freeze
SEVERITY_ORDER =
SEVERITIES.each_with_index.to_h.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#codeObject

Returns the value of attribute code

Returns:

  • (Object)

    the current value of code



1
2
3
# File 'lib/finding.rb', line 1

def code
  @code
end

#fileObject

Returns the value of attribute file

Returns:

  • (Object)

    the current value of file



1
2
3
# File 'lib/finding.rb', line 1

def file
  @file
end

#fixObject

Returns the value of attribute fix

Returns:

  • (Object)

    the current value of fix



1
2
3
# File 'lib/finding.rb', line 1

def fix
  @fix
end

#lineObject

Returns the value of attribute line

Returns:

  • (Object)

    the current value of line



1
2
3
# File 'lib/finding.rb', line 1

def line
  @line
end

#messageObject

Returns the value of attribute message

Returns:

  • (Object)

    the current value of message



1
2
3
# File 'lib/finding.rb', line 1

def message
  @message
end

#ruleObject

Returns the value of attribute rule

Returns:

  • (Object)

    the current value of rule



1
2
3
# File 'lib/finding.rb', line 1

def rule
  @rule
end

#severityObject

Returns the value of attribute severity

Returns:

  • (Object)

    the current value of severity



1
2
3
# File 'lib/finding.rb', line 1

def severity
  @severity
end

Instance Method Details

#<=>(other) ⇒ Object



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

def <=>(other)
    (SEVERITY_ORDER[severity] || 99) <=> (SEVERITY_ORDER[other.severity] || 99)
end

#critical?Boolean

Returns:

  • (Boolean)


11
# File 'lib/finding.rb', line 11

def critical? = severity == :critical

#high?Boolean

Returns:

  • (Boolean)


12
# File 'lib/finding.rb', line 12

def high?     = severity == :high

#low?Boolean

Returns:

  • (Boolean)


14
# File 'lib/finding.rb', line 14

def low?      = severity == :low

#medium?Boolean

Returns:

  • (Boolean)


13
# File 'lib/finding.rb', line 13

def medium?   = severity == :medium

#to_hObject



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/finding.rb', line 16

def to_h
    {
        rule: rule,
        severity: severity.to_s,
        file: file,
        line: line,
        code: code,
        message: message,
        fix: fix
    }
end