Class: Ukiryu::Definition::DefinitionLinter::LintResult
- Inherits:
-
Object
- Object
- Ukiryu::Definition::DefinitionLinter::LintResult
- Defined in:
- lib/ukiryu/definition/definition_linter.rb
Overview
Linting result
Instance Attribute Summary collapse
-
#issues ⇒ Object
readonly
Returns the value of attribute issues.
Instance Method Summary collapse
-
#by_severity(severity) ⇒ Array<LintIssue>
Get issues by severity.
-
#count ⇒ Integer
Get total issue count.
-
#count_by_severity(severity) ⇒ Integer
Get count by severity.
-
#errors ⇒ Array<LintIssue>
Get errors.
-
#has_errors? ⇒ Boolean
Check if there are any errors.
-
#has_issues? ⇒ Boolean
Check if there are any issues.
-
#infos ⇒ Array<LintIssue>
Get info issues.
-
#initialize(issues = []) ⇒ LintResult
constructor
A new instance of LintResult.
-
#styles ⇒ Array<LintIssue>
Get style issues.
-
#to_h ⇒ Hash
Convert to hash.
-
#to_s ⇒ String
Format as string.
-
#warnings ⇒ Array<LintIssue>
Get warnings.
Constructor Details
#initialize(issues = []) ⇒ LintResult
Returns a new instance of LintResult.
14 15 16 |
# File 'lib/ukiryu/definition/definition_linter.rb', line 14 def initialize(issues = []) @issues = issues end |
Instance Attribute Details
#issues ⇒ Object (readonly)
Returns the value of attribute issues.
12 13 14 |
# File 'lib/ukiryu/definition/definition_linter.rb', line 12 def issues @issues end |
Instance Method Details
#by_severity(severity) ⇒ Array<LintIssue>
Get issues by severity
22 23 24 |
# File 'lib/ukiryu/definition/definition_linter.rb', line 22 def by_severity(severity) @issues.select { |i| i.severity == severity } end |
#count ⇒ Integer
Get total issue count
71 72 73 |
# File 'lib/ukiryu/definition/definition_linter.rb', line 71 def count @issues.length end |
#count_by_severity(severity) ⇒ Integer
Get count by severity
79 80 81 |
# File 'lib/ukiryu/definition/definition_linter.rb', line 79 def count_by_severity(severity) by_severity(severity).length end |
#errors ⇒ Array<LintIssue>
Get errors
29 30 31 |
# File 'lib/ukiryu/definition/definition_linter.rb', line 29 def errors by_severity(LintIssue::SEVERITY_ERROR) end |
#has_errors? ⇒ Boolean
Check if there are any errors
64 65 66 |
# File 'lib/ukiryu/definition/definition_linter.rb', line 64 def has_errors? !errors.empty? end |
#has_issues? ⇒ Boolean
Check if there are any issues
57 58 59 |
# File 'lib/ukiryu/definition/definition_linter.rb', line 57 def has_issues? !@issues.empty? end |
#infos ⇒ Array<LintIssue>
Get info issues
43 44 45 |
# File 'lib/ukiryu/definition/definition_linter.rb', line 43 def infos by_severity(LintIssue::SEVERITY_INFO) end |
#styles ⇒ Array<LintIssue>
Get style issues
50 51 52 |
# File 'lib/ukiryu/definition/definition_linter.rb', line 50 def styles by_severity(LintIssue::SEVERITY_STYLE) end |
#to_h ⇒ Hash
Convert to hash
86 87 88 89 90 91 92 93 94 95 |
# File 'lib/ukiryu/definition/definition_linter.rb', line 86 def to_h { issues: @issues.map(&:to_h), total_count: count, error_count: errors.length, warning_count: warnings.length, info_count: infos.length, style_count: styles.length } end |
#to_s ⇒ String
Format as string
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 |
# File 'lib/ukiryu/definition/definition_linter.rb', line 100 def to_s return 'No issues found' unless has_issues? output = [] output << "Found #{count} issue(s):" { LintIssue::SEVERITY_ERROR => errors, LintIssue::SEVERITY_WARNING => warnings, LintIssue::SEVERITY_INFO => infos, LintIssue::SEVERITY_STYLE => styles }.each do |severity, issues| next if issues.empty? output << '' output << "#{severity.to_s.upcase}:" issues.each { |issue| output << " #{issue}" } end output.join("\n") end |
#warnings ⇒ Array<LintIssue>
Get warnings
36 37 38 |
# File 'lib/ukiryu/definition/definition_linter.rb', line 36 def warnings by_severity(LintIssue::SEVERITY_WARNING) end |