Class: SvgConform::QualityMetrics::ErrorAnalyzer
- Inherits:
-
Object
- Object
- SvgConform::QualityMetrics::ErrorAnalyzer
- Defined in:
- lib/svg_conform/quality_metrics/error_analyzer.rb
Overview
Analyzes validation errors and produces a structured ErrorBreakdown.
Instance Method Summary collapse
-
#analyze(validation_result) ⇒ ErrorBreakdown
Analyze validation result and produce an ErrorBreakdown.
-
#determine_health(breakdown) ⇒ Symbol
Determine content health from breakdown.
-
#initialize(config) ⇒ ErrorAnalyzer
constructor
A new instance of ErrorAnalyzer.
Constructor Details
#initialize(config) ⇒ ErrorAnalyzer
Returns a new instance of ErrorAnalyzer.
18 19 20 |
# File 'lib/svg_conform/quality_metrics/error_analyzer.rb', line 18 def initialize(config) @config = config end |
Instance Method Details
#analyze(validation_result) ⇒ ErrorBreakdown
Analyze validation result and produce an ErrorBreakdown
26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/svg_conform/quality_metrics/error_analyzer.rb', line 26 def analyze(validation_result) errors = validation_result.errors || [] ErrorBreakdown.new( total: errors.size, critical: count_by_severity(errors, :critical), high: count_by_severity(errors, :high), medium: count_by_severity(errors, :medium), low: count_by_severity(errors, :low), remediable: count_remediable(errors), non_remediable: count_non_remediable(errors), ) end |
#determine_health(breakdown) ⇒ Symbol
Determine content health from breakdown
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/svg_conform/quality_metrics/error_analyzer.rb', line 44 def determine_health(breakdown) return :good if breakdown.clean? # Check for severe issues if @config.content_health.severe_issues_any_critical && breakdown.has_critical? return :severe_issues end if breakdown.total >= @config.content_health.severe_issues_min_errors return :severe_issues end # Check for moderate issues if @config.content_health.moderate_issues_any_high && breakdown.high.positive? return :moderate_issues end if breakdown.total >= @config.content_health.moderate_issues_max_errors return :moderate_issues end # Check for minor issues if breakdown.total <= @config.content_health.minor_issues_max_errors return :minor_issues end :moderate_issues end |