Class: Audition::Finding

Inherits:
Data
  • Object
show all
Defined in:
lib/audition/finding.rb

Overview

One diagnosed problem: what was found (message), the Ractor rule it violates (why), what to write instead (fix), where (path/line/source), and optionally a machine-applicable Autofix. Produced by static checks, the graph audit, and the dynamic prober alike.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source: nil, autofix: nil, dependency: false, **rest) ⇒ Finding

Returns a new instance of Finding.



71
72
73
74
# File 'lib/audition/finding.rb', line 71

def initialize(source: nil, autofix: nil, dependency: false,
  **rest)
  super
end

Instance Attribute Details

#autofixAutofix? (readonly)

Returns machine-applicable correction.

Returns:

  • (Autofix, nil)

    machine-applicable correction



67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/audition/finding.rb', line 67

Finding = Data.define(
  :check, :severity, :message, :why, :fix,
  :path, :line, :source, :autofix, :dependency
) do
  def initialize(source: nil, autofix: nil, dependency: false,
    **rest)
    super
  end

  # @return [Boolean] whether severity is `:error`
  def error? = severity == :error

  # True when the problem lives in a dependency's source, not the
  # audited target: real, but not the target's bug to fix.
  #
  # @return [Boolean]
  def dependency? = dependency

  # @return [Boolean] whether an {Autofix} is attached
  def fixable? = !autofix.nil?

  # @return [Integer] rank from {SEVERITIES}, higher is worse
  def severity_rank = SEVERITIES.fetch(severity)

  # @return [String] "path:line", or just the path label
  def location = line ? "#{path}:#{line}" : path
end

#checkString (readonly)

Returns kebab-case check identifier.

Returns:

  • (String)

    kebab-case check identifier



67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/audition/finding.rb', line 67

Finding = Data.define(
  :check, :severity, :message, :why, :fix,
  :path, :line, :source, :autofix, :dependency
) do
  def initialize(source: nil, autofix: nil, dependency: false,
    **rest)
    super
  end

  # @return [Boolean] whether severity is `:error`
  def error? = severity == :error

  # True when the problem lives in a dependency's source, not the
  # audited target: real, but not the target's bug to fix.
  #
  # @return [Boolean]
  def dependency? = dependency

  # @return [Boolean] whether an {Autofix} is attached
  def fixable? = !autofix.nil?

  # @return [Integer] rank from {SEVERITIES}, higher is worse
  def severity_rank = SEVERITIES.fetch(severity)

  # @return [String] "path:line", or just the path label
  def location = line ? "#{path}:#{line}" : path
end

#dependencyBoolean (readonly)

Returns see #dependency?.

Returns:



67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/audition/finding.rb', line 67

Finding = Data.define(
  :check, :severity, :message, :why, :fix,
  :path, :line, :source, :autofix, :dependency
) do
  def initialize(source: nil, autofix: nil, dependency: false,
    **rest)
    super
  end

  # @return [Boolean] whether severity is `:error`
  def error? = severity == :error

  # True when the problem lives in a dependency's source, not the
  # audited target: real, but not the target's bug to fix.
  #
  # @return [Boolean]
  def dependency? = dependency

  # @return [Boolean] whether an {Autofix} is attached
  def fixable? = !autofix.nil?

  # @return [Integer] rank from {SEVERITIES}, higher is worse
  def severity_rank = SEVERITIES.fetch(severity)

  # @return [String] "path:line", or just the path label
  def location = line ? "#{path}:#{line}" : path
end

#fixString (readonly)

Returns suggested remediation.

Returns:

  • (String)

    suggested remediation



67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/audition/finding.rb', line 67

Finding = Data.define(
  :check, :severity, :message, :why, :fix,
  :path, :line, :source, :autofix, :dependency
) do
  def initialize(source: nil, autofix: nil, dependency: false,
    **rest)
    super
  end

  # @return [Boolean] whether severity is `:error`
  def error? = severity == :error

  # True when the problem lives in a dependency's source, not the
  # audited target: real, but not the target's bug to fix.
  #
  # @return [Boolean]
  def dependency? = dependency

  # @return [Boolean] whether an {Autofix} is attached
  def fixable? = !autofix.nil?

  # @return [Integer] rank from {SEVERITIES}, higher is worse
  def severity_rank = SEVERITIES.fetch(severity)

  # @return [String] "path:line", or just the path label
  def location = line ? "#{path}:#{line}" : path
end

#lineInteger? (readonly)

Returns 1-based line, nil for whole-target.

Returns:

  • (Integer, nil)

    1-based line, nil for whole-target



67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/audition/finding.rb', line 67

Finding = Data.define(
  :check, :severity, :message, :why, :fix,
  :path, :line, :source, :autofix, :dependency
) do
  def initialize(source: nil, autofix: nil, dependency: false,
    **rest)
    super
  end

  # @return [Boolean] whether severity is `:error`
  def error? = severity == :error

  # True when the problem lives in a dependency's source, not the
  # audited target: real, but not the target's bug to fix.
  #
  # @return [Boolean]
  def dependency? = dependency

  # @return [Boolean] whether an {Autofix} is attached
  def fixable? = !autofix.nil?

  # @return [Integer] rank from {SEVERITIES}, higher is worse
  def severity_rank = SEVERITIES.fetch(severity)

  # @return [String] "path:line", or just the path label
  def location = line ? "#{path}:#{line}" : path
end

#messageString (readonly)

Returns one-line statement of the problem.

Returns:

  • (String)

    one-line statement of the problem



67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/audition/finding.rb', line 67

Finding = Data.define(
  :check, :severity, :message, :why, :fix,
  :path, :line, :source, :autofix, :dependency
) do
  def initialize(source: nil, autofix: nil, dependency: false,
    **rest)
    super
  end

  # @return [Boolean] whether severity is `:error`
  def error? = severity == :error

  # True when the problem lives in a dependency's source, not the
  # audited target: real, but not the target's bug to fix.
  #
  # @return [Boolean]
  def dependency? = dependency

  # @return [Boolean] whether an {Autofix} is attached
  def fixable? = !autofix.nil?

  # @return [Integer] rank from {SEVERITIES}, higher is worse
  def severity_rank = SEVERITIES.fetch(severity)

  # @return [String] "path:line", or just the path label
  def location = line ? "#{path}:#{line}" : path
end

#pathString (readonly)

Returns file path, or a label for runtime findings.

Returns:

  • (String)

    file path, or a label for runtime findings



67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/audition/finding.rb', line 67

Finding = Data.define(
  :check, :severity, :message, :why, :fix,
  :path, :line, :source, :autofix, :dependency
) do
  def initialize(source: nil, autofix: nil, dependency: false,
    **rest)
    super
  end

  # @return [Boolean] whether severity is `:error`
  def error? = severity == :error

  # True when the problem lives in a dependency's source, not the
  # audited target: real, but not the target's bug to fix.
  #
  # @return [Boolean]
  def dependency? = dependency

  # @return [Boolean] whether an {Autofix} is attached
  def fixable? = !autofix.nil?

  # @return [Integer] rank from {SEVERITIES}, higher is worse
  def severity_rank = SEVERITIES.fetch(severity)

  # @return [String] "path:line", or just the path label
  def location = line ? "#{path}:#{line}" : path
end

#severitySymbol (readonly)

Returns :error, :warning, or :info.

Returns:

  • (Symbol)

    :error, :warning, or :info



67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/audition/finding.rb', line 67

Finding = Data.define(
  :check, :severity, :message, :why, :fix,
  :path, :line, :source, :autofix, :dependency
) do
  def initialize(source: nil, autofix: nil, dependency: false,
    **rest)
    super
  end

  # @return [Boolean] whether severity is `:error`
  def error? = severity == :error

  # True when the problem lives in a dependency's source, not the
  # audited target: real, but not the target's bug to fix.
  #
  # @return [Boolean]
  def dependency? = dependency

  # @return [Boolean] whether an {Autofix} is attached
  def fixable? = !autofix.nil?

  # @return [Integer] rank from {SEVERITIES}, higher is worse
  def severity_rank = SEVERITIES.fetch(severity)

  # @return [String] "path:line", or just the path label
  def location = line ? "#{path}:#{line}" : path
end

#sourceString? (readonly)

Returns the offending source line, stripped.

Returns:

  • (String, nil)

    the offending source line, stripped



67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/audition/finding.rb', line 67

Finding = Data.define(
  :check, :severity, :message, :why, :fix,
  :path, :line, :source, :autofix, :dependency
) do
  def initialize(source: nil, autofix: nil, dependency: false,
    **rest)
    super
  end

  # @return [Boolean] whether severity is `:error`
  def error? = severity == :error

  # True when the problem lives in a dependency's source, not the
  # audited target: real, but not the target's bug to fix.
  #
  # @return [Boolean]
  def dependency? = dependency

  # @return [Boolean] whether an {Autofix} is attached
  def fixable? = !autofix.nil?

  # @return [Integer] rank from {SEVERITIES}, higher is worse
  def severity_rank = SEVERITIES.fetch(severity)

  # @return [String] "path:line", or just the path label
  def location = line ? "#{path}:#{line}" : path
end

#whyString (readonly)

Returns the Ractor rule behind the finding.

Returns:

  • (String)

    the Ractor rule behind the finding



67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/audition/finding.rb', line 67

Finding = Data.define(
  :check, :severity, :message, :why, :fix,
  :path, :line, :source, :autofix, :dependency
) do
  def initialize(source: nil, autofix: nil, dependency: false,
    **rest)
    super
  end

  # @return [Boolean] whether severity is `:error`
  def error? = severity == :error

  # True when the problem lives in a dependency's source, not the
  # audited target: real, but not the target's bug to fix.
  #
  # @return [Boolean]
  def dependency? = dependency

  # @return [Boolean] whether an {Autofix} is attached
  def fixable? = !autofix.nil?

  # @return [Integer] rank from {SEVERITIES}, higher is worse
  def severity_rank = SEVERITIES.fetch(severity)

  # @return [String] "path:line", or just the path label
  def location = line ? "#{path}:#{line}" : path
end

Instance Method Details

#dependency?Boolean

True when the problem lives in a dependency's source, not the audited target: real, but not the target's bug to fix.

Returns:

  • (Boolean)


83
# File 'lib/audition/finding.rb', line 83

def dependency? = dependency

#error?Boolean

Returns whether severity is :error.

Returns:

  • (Boolean)

    whether severity is :error



77
# File 'lib/audition/finding.rb', line 77

def error? = severity == :error

#fixable?Boolean

Returns whether an Autofix is attached.

Returns:

  • (Boolean)

    whether an Autofix is attached



86
# File 'lib/audition/finding.rb', line 86

def fixable? = !autofix.nil?

#locationString

Returns "path:line", or just the path label.

Returns:

  • (String)

    "path:line", or just the path label



92
# File 'lib/audition/finding.rb', line 92

def location = line ? "#{path}:#{line}" : path

#severity_rankInteger

Returns rank from SEVERITIES, higher is worse.

Returns:

  • (Integer)

    rank from SEVERITIES, higher is worse



89
# File 'lib/audition/finding.rb', line 89

def severity_rank = SEVERITIES.fetch(severity)