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.
-
#subject ⇒ String?
readonly
The object a finding is about, in a form the dynamic probe can match ("Owner/@ivar"), so a runtime proof of shareability can retire the static guess.
-
#test ⇒ Boolean
readonly
See #test?.
-
#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, test: false, subject: nil, **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.
-
#test? ⇒ Boolean
True when the problem lives in the target's test or spec code: real, but never loaded by the production boot.
Constructor Details
#initialize(source: nil, autofix: nil, dependency: false, test: false, subject: nil, **rest) ⇒ Finding
Returns a new instance of Finding.
77 78 79 80 |
# File 'lib/audition/finding.rb', line 77 def initialize(source: nil, autofix: nil, dependency: false, test: false, subject: nil, **rest) super end |
Instance Attribute Details
#autofix ⇒ Autofix? (readonly)
Returns machine-applicable correction.
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/audition/finding.rb', line 73 Finding = Data.define( :check, :severity, :message, :why, :fix, :path, :line, :source, :autofix, :dependency, :test, :subject ) do def initialize(source: nil, autofix: nil, dependency: false, test: false, subject: nil, **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 # True when the problem lives in the target's test or spec # code: real, but never loaded by the production boot. # # @return [Boolean] def test? = test # @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.
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/audition/finding.rb', line 73 Finding = Data.define( :check, :severity, :message, :why, :fix, :path, :line, :source, :autofix, :dependency, :test, :subject ) do def initialize(source: nil, autofix: nil, dependency: false, test: false, subject: nil, **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 # True when the problem lives in the target's test or spec # code: real, but never loaded by the production boot. # # @return [Boolean] def test? = test # @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?.
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/audition/finding.rb', line 73 Finding = Data.define( :check, :severity, :message, :why, :fix, :path, :line, :source, :autofix, :dependency, :test, :subject ) do def initialize(source: nil, autofix: nil, dependency: false, test: false, subject: nil, **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 # True when the problem lives in the target's test or spec # code: real, but never loaded by the production boot. # # @return [Boolean] def test? = test # @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.
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/audition/finding.rb', line 73 Finding = Data.define( :check, :severity, :message, :why, :fix, :path, :line, :source, :autofix, :dependency, :test, :subject ) do def initialize(source: nil, autofix: nil, dependency: false, test: false, subject: nil, **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 # True when the problem lives in the target's test or spec # code: real, but never loaded by the production boot. # # @return [Boolean] def test? = test # @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.
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/audition/finding.rb', line 73 Finding = Data.define( :check, :severity, :message, :why, :fix, :path, :line, :source, :autofix, :dependency, :test, :subject ) do def initialize(source: nil, autofix: nil, dependency: false, test: false, subject: nil, **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 # True when the problem lives in the target's test or spec # code: real, but never loaded by the production boot. # # @return [Boolean] def test? = test # @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.
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/audition/finding.rb', line 73 Finding = Data.define( :check, :severity, :message, :why, :fix, :path, :line, :source, :autofix, :dependency, :test, :subject ) do def initialize(source: nil, autofix: nil, dependency: false, test: false, subject: nil, **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 # True when the problem lives in the target's test or spec # code: real, but never loaded by the production boot. # # @return [Boolean] def test? = test # @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.
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/audition/finding.rb', line 73 Finding = Data.define( :check, :severity, :message, :why, :fix, :path, :line, :source, :autofix, :dependency, :test, :subject ) do def initialize(source: nil, autofix: nil, dependency: false, test: false, subject: nil, **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 # True when the problem lives in the target's test or spec # code: real, but never loaded by the production boot. # # @return [Boolean] def test? = test # @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.
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/audition/finding.rb', line 73 Finding = Data.define( :check, :severity, :message, :why, :fix, :path, :line, :source, :autofix, :dependency, :test, :subject ) do def initialize(source: nil, autofix: nil, dependency: false, test: false, subject: nil, **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 # True when the problem lives in the target's test or spec # code: real, but never loaded by the production boot. # # @return [Boolean] def test? = test # @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.
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/audition/finding.rb', line 73 Finding = Data.define( :check, :severity, :message, :why, :fix, :path, :line, :source, :autofix, :dependency, :test, :subject ) do def initialize(source: nil, autofix: nil, dependency: false, test: false, subject: nil, **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 # True when the problem lives in the target's test or spec # code: real, but never loaded by the production boot. # # @return [Boolean] def test? = test # @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 |
#subject ⇒ String? (readonly)
Returns the object a finding is about, in a form the dynamic probe can match ("Owner/@ivar"), so a runtime proof of shareability can retire the static guess.
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/audition/finding.rb', line 73 Finding = Data.define( :check, :severity, :message, :why, :fix, :path, :line, :source, :autofix, :dependency, :test, :subject ) do def initialize(source: nil, autofix: nil, dependency: false, test: false, subject: nil, **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 # True when the problem lives in the target's test or spec # code: real, but never loaded by the production boot. # # @return [Boolean] def test? = test # @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 |
#test ⇒ Boolean (readonly)
Returns see #test?.
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/audition/finding.rb', line 73 Finding = Data.define( :check, :severity, :message, :why, :fix, :path, :line, :source, :autofix, :dependency, :test, :subject ) do def initialize(source: nil, autofix: nil, dependency: false, test: false, subject: nil, **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 # True when the problem lives in the target's test or spec # code: real, but never loaded by the production boot. # # @return [Boolean] def test? = test # @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.
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/audition/finding.rb', line 73 Finding = Data.define( :check, :severity, :message, :why, :fix, :path, :line, :source, :autofix, :dependency, :test, :subject ) do def initialize(source: nil, autofix: nil, dependency: false, test: false, subject: nil, **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 # True when the problem lives in the target's test or spec # code: real, but never loaded by the production boot. # # @return [Boolean] def test? = test # @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.
89 |
# File 'lib/audition/finding.rb', line 89 def dependency? = dependency |
#error? ⇒ Boolean
Returns whether severity is :error.
83 |
# File 'lib/audition/finding.rb', line 83 def error? = severity == :error |
#fixable? ⇒ Boolean
Returns whether an Autofix is attached.
98 |
# File 'lib/audition/finding.rb', line 98 def fixable? = !autofix.nil? |
#location ⇒ String
Returns "path:line", or just the path label.
104 |
# File 'lib/audition/finding.rb', line 104 def location = line ? "#{path}:#{line}" : path |
#severity_rank ⇒ Integer
Returns rank from SEVERITIES, higher is worse.
101 |
# File 'lib/audition/finding.rb', line 101 def severity_rank = SEVERITIES.fetch(severity) |
#test? ⇒ Boolean
True when the problem lives in the target's test or spec code: real, but never loaded by the production boot.
95 |
# File 'lib/audition/finding.rb', line 95 def test? = test |