Class: Audition::Finding
- Inherits:
-
Data
- Object
- Data
- Audition::Finding
- 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
-
#autofix ⇒ Autofix?
readonly
Machine-applicable correction.
-
#check ⇒ String
readonly
Kebab-case check identifier.
-
#dependency ⇒ Boolean
readonly
See #dependency?.
-
#fix ⇒ String
readonly
Suggested remediation.
-
#line ⇒ Integer?
readonly
1-based line, nil for whole-target.
-
#message ⇒ String
readonly
One-line statement of the problem.
-
#path ⇒ String
readonly
File path, or a label for runtime findings.
-
#severity ⇒ Symbol
readonly
:error,:warning, or:info. -
#source ⇒ String?
readonly
The offending source line, stripped.
-
#why ⇒ String
readonly
The Ractor rule behind the finding.
Instance Method Summary collapse
-
#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.
-
#error? ⇒ Boolean
Whether severity is
:error. -
#fixable? ⇒ Boolean
Whether an Autofix is attached.
-
#initialize(source: nil, autofix: nil, dependency: false, **rest) ⇒ Finding
constructor
A new instance of Finding.
-
#location ⇒ String
"path:line", or just the path label.
-
#severity_rank ⇒ Integer
Rank from SEVERITIES, higher is worse.
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
#autofix ⇒ Autofix? (readonly)
Returns 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 |
#check ⇒ String (readonly)
Returns 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 |
#dependency ⇒ Boolean (readonly)
Returns see #dependency?.
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 |
#fix ⇒ String (readonly)
Returns 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 |
#line ⇒ Integer? (readonly)
Returns 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 |
#message ⇒ String (readonly)
Returns 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 |
#path ⇒ String (readonly)
Returns 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 |
#severity ⇒ Symbol (readonly)
Returns :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 |
#source ⇒ String? (readonly)
Returns 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 |
#why ⇒ String (readonly)
Returns 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.
83 |
# File 'lib/audition/finding.rb', line 83 def dependency? = dependency |
#error? ⇒ Boolean
Returns whether severity is :error.
77 |
# File 'lib/audition/finding.rb', line 77 def error? = severity == :error |
#fixable? ⇒ Boolean
Returns whether an Autofix is attached.
86 |
# File 'lib/audition/finding.rb', line 86 def fixable? = !autofix.nil? |
#location ⇒ String
Returns "path:line", or just the path label.
92 |
# File 'lib/audition/finding.rb', line 92 def location = line ? "#{path}:#{line}" : path |
#severity_rank ⇒ Integer
Returns rank from SEVERITIES, higher is worse.
89 |
# File 'lib/audition/finding.rb', line 89 def severity_rank = SEVERITIES.fetch(severity) |