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.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#fileObject (readonly)

Returns the value of attribute file

Returns:

  • (Object)

    the current value of file



10
11
12
# File 'lib/sharekit/cli/finding.rb', line 10

def file
  @file
end

#lineObject (readonly)

Returns the value of attribute line

Returns:

  • (Object)

    the current value of line



10
11
12
# File 'lib/sharekit/cli/finding.rb', line 10

def line
  @line
end

#previewObject (readonly)

Returns the value of attribute preview

Returns:

  • (Object)

    the current value of preview



10
11
12
# File 'lib/sharekit/cli/finding.rb', line 10

def preview
  @preview
end

#ruleObject (readonly)

Returns the value of attribute rule

Returns:

  • (Object)

    the current value of rule



10
11
12
# File 'lib/sharekit/cli/finding.rb', line 10

def rule
  @rule
end

#severityObject (readonly)

Returns the value of attribute severity

Returns:

  • (Object)

    the current value of severity



10
11
12
# File 'lib/sharekit/cli/finding.rb', line 10

def severity
  @severity
end

Instance Method Details

#<=>(other) ⇒ Object



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

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

#high?Boolean

Returns:

  • (Boolean)


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

def high? = severity == :high