Class: Sharekit::Cli::Finding

Inherits:
Data
  • Object
show all
Includes:
Comparable
Defined in:
lib/sharekit/cli/finding.rb

Overview

Immutable value object for one scan hit. Data.define gives us structural equality and Hash-pattern deconstruction (in {severity:, rule:}) for free — a plain TS interface has neither.

The triage fields default to nil, so a scan-only run builds a Finding the same way it always did, and Triage layers verdicts on with #with rather than mutating anything.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(verdict: nil, confidence: nil, rationale: nil) ⇒ Finding

Returns a new instance of Finding.



18
# File 'lib/sharekit/cli/finding.rb', line 18

def initialize(verdict: nil, confidence: nil, rationale: nil, **) = super

Instance Attribute Details

#confidenceObject (readonly)

Returns the value of attribute confidence

Returns:

  • (Object)

    the current value of confidence



14
15
16
# File 'lib/sharekit/cli/finding.rb', line 14

def confidence
  @confidence
end

#fileObject (readonly)

Returns the value of attribute file

Returns:

  • (Object)

    the current value of file



14
15
16
# File 'lib/sharekit/cli/finding.rb', line 14

def file
  @file
end

#lineObject (readonly)

Returns the value of attribute line

Returns:

  • (Object)

    the current value of line



14
15
16
# File 'lib/sharekit/cli/finding.rb', line 14

def line
  @line
end

#previewObject (readonly)

Returns the value of attribute preview

Returns:

  • (Object)

    the current value of preview



14
15
16
# File 'lib/sharekit/cli/finding.rb', line 14

def preview
  @preview
end

#rationaleObject (readonly)

Returns the value of attribute rationale

Returns:

  • (Object)

    the current value of rationale



14
15
16
# File 'lib/sharekit/cli/finding.rb', line 14

def rationale
  @rationale
end

#ruleObject (readonly)

Returns the value of attribute rule

Returns:

  • (Object)

    the current value of rule



14
15
16
# File 'lib/sharekit/cli/finding.rb', line 14

def rule
  @rule
end

#severityObject (readonly)

Returns the value of attribute severity

Returns:

  • (Object)

    the current value of severity



14
15
16
# File 'lib/sharekit/cli/finding.rb', line 14

def severity
  @severity
end

#verdictObject (readonly)

Returns the value of attribute verdict

Returns:

  • (Object)

    the current value of verdict



14
15
16
# File 'lib/sharekit/cli/finding.rb', line 14

def verdict
  @verdict
end

Instance Method Details

#<=>(other) ⇒ Object



20
21
22
# File 'lib/sharekit/cli/finding.rb', line 20

def <=>(other)
  SEVERITY_RANK.fetch(severity) <=> SEVERITY_RANK.fetch(other.severity)
end

#high?Boolean

Returns:

  • (Boolean)


24
# File 'lib/sharekit/cli/finding.rb', line 24

def high? = severity == :high

#triaged?Boolean

Returns:

  • (Boolean)


25
# File 'lib/sharekit/cli/finding.rb', line 25

def triaged? = !verdict.nil?