Class: Ace::Lint::Models::LintResult
- Inherits:
-
Struct
- Object
- Struct
- Ace::Lint::Models::LintResult
- Defined in:
- lib/ace/lint/models/lint_result.rb
Overview
Represents the validation result for a single file
Instance Attribute Summary collapse
-
#errors ⇒ Array<ValidationError>
List of errors.
-
#file_path ⇒ String
Path to the validated file.
-
#formatted ⇒ Boolean
Whether file was formatted.
-
#runner ⇒ Symbol
Which linter was used (:standardrb, :rubocop, nil).
-
#skip_reason ⇒ String
Reason for skipping (when skipped is true).
-
#skipped ⇒ Boolean
Whether file was skipped (unsupported type).
-
#success ⇒ Boolean
Whether validation passed.
-
#warnings ⇒ Array<ValidationError>
List of warnings.
Class Method Summary collapse
-
.skipped(file_path:, reason: "Unsupported file type") ⇒ LintResult
Factory method for skipped results.
Instance Method Summary collapse
- #error_count ⇒ Object
- #failed? ⇒ Boolean
- #formatted? ⇒ Boolean
- #has_errors? ⇒ Boolean
- #has_warnings? ⇒ Boolean
-
#initialize(file_path:, success: true, errors: [], warnings: [], formatted: false, skipped: false, skip_reason: "Unsupported file type", runner: nil) ⇒ LintResult
constructor
A new instance of LintResult.
- #skipped? ⇒ Boolean
- #success? ⇒ Boolean
-
#to_h ⇒ Hash
Convert result to hash for JSON serialization.
- #warning_count ⇒ Object
Constructor Details
#initialize(file_path:, success: true, errors: [], warnings: [], formatted: false, skipped: false, skip_reason: "Unsupported file type", runner: nil) ⇒ LintResult
Returns a new instance of LintResult.
18 19 20 |
# File 'lib/ace/lint/models/lint_result.rb', line 18 def initialize(file_path:, success: true, errors: [], warnings: [], formatted: false, skipped: false, skip_reason: "Unsupported file type", runner: nil) super end |
Instance Attribute Details
#errors ⇒ Array<ValidationError>
List of errors
17 18 19 |
# File 'lib/ace/lint/models/lint_result.rb', line 17 def errors @errors end |
#file_path ⇒ String
Path to the validated file
17 18 19 |
# File 'lib/ace/lint/models/lint_result.rb', line 17 def file_path @file_path end |
#formatted ⇒ Boolean
Whether file was formatted
17 18 19 |
# File 'lib/ace/lint/models/lint_result.rb', line 17 def formatted @formatted end |
#runner ⇒ Symbol
Which linter was used (:standardrb, :rubocop, nil)
17 18 19 |
# File 'lib/ace/lint/models/lint_result.rb', line 17 def runner @runner end |
#skip_reason ⇒ String
Reason for skipping (when skipped is true)
17 18 19 |
# File 'lib/ace/lint/models/lint_result.rb', line 17 def skip_reason @skip_reason end |
#skipped ⇒ Boolean
Whether file was skipped (unsupported type)
17 18 19 |
# File 'lib/ace/lint/models/lint_result.rb', line 17 def skipped @skipped end |
#success ⇒ Boolean
Whether validation passed
17 18 19 |
# File 'lib/ace/lint/models/lint_result.rb', line 17 def success @success end |
#warnings ⇒ Array<ValidationError>
List of warnings
17 18 19 |
# File 'lib/ace/lint/models/lint_result.rb', line 17 def warnings @warnings end |
Class Method Details
.skipped(file_path:, reason: "Unsupported file type") ⇒ LintResult
Factory method for skipped results
58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/ace/lint/models/lint_result.rb', line 58 def self.skipped(file_path:, reason: "Unsupported file type") new( file_path: file_path, success: true, errors: [], warnings: [], formatted: false, skipped: true, skip_reason: reason ) end |
Instance Method Details
#error_count ⇒ Object
46 47 48 |
# File 'lib/ace/lint/models/lint_result.rb', line 46 def error_count errors.size end |
#failed? ⇒ Boolean
26 27 28 |
# File 'lib/ace/lint/models/lint_result.rb', line 26 def failed? !success && !skipped end |
#formatted? ⇒ Boolean
30 31 32 |
# File 'lib/ace/lint/models/lint_result.rb', line 30 def formatted? formatted end |
#has_errors? ⇒ Boolean
38 39 40 |
# File 'lib/ace/lint/models/lint_result.rb', line 38 def has_errors? errors.any? end |
#has_warnings? ⇒ Boolean
42 43 44 |
# File 'lib/ace/lint/models/lint_result.rb', line 42 def has_warnings? warnings.any? end |
#skipped? ⇒ Boolean
34 35 36 |
# File 'lib/ace/lint/models/lint_result.rb', line 34 def skipped? skipped end |
#success? ⇒ Boolean
22 23 24 |
# File 'lib/ace/lint/models/lint_result.rb', line 22 def success? success end |
#to_h ⇒ Hash
Convert result to hash for JSON serialization
72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/ace/lint/models/lint_result.rb', line 72 def to_h { file_path: file_path, success: success, errors: errors.map(&:to_h), warnings: warnings.map(&:to_h), formatted: formatted, runner: runner, skipped: skipped, skip_reason: skip_reason } end |
#warning_count ⇒ Object
50 51 52 |
# File 'lib/ace/lint/models/lint_result.rb', line 50 def warning_count warnings.size end |