Class: Yard::Lint::Validators::Documentation::BlankLineBeforeDefinition::Parser
- Inherits:
-
Parsers::Base
- Object
- Parsers::Base
- Yard::Lint::Validators::Documentation::BlankLineBeforeDefinition::Parser
- Defined in:
- lib/yard/lint/validators/documentation/blank_line_before_definition/parser.rb
Overview
Parses YARD output for blank line before definition violations
Instance Method Summary collapse
-
#call(output) ⇒ Array<Hash>
Parse YARD output into structured violations.
Methods inherited from Parsers::Base
Instance Method Details
#call(output) ⇒ Array<Hash>
Parse YARD output into structured violations
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/yard/lint/validators/documentation/blank_line_before_definition/parser.rb', line 13 def call(output) return [] if output.nil? || output.empty? violations = [] lines = output.lines.map(&:chomp) i = 0 while i < lines.size line = lines[i] # Match location line: "file:line: object_name" if (location_match = line.match(/^(.+):(\d+): (.+)$/)) file_path = location_match[1] object_line = location_match[2].to_i object_name = location_match[3] # Next line contains violation details i += 1 next unless i < lines.size # Parse violation: "single:1" or "orphaned:3" detail_parts = lines[i].split(':', 2) next unless detail_parts.size == 2 violation_type = detail_parts[0] blank_count = detail_parts[1].to_i violations << { location: file_path, line: object_line, object_name: object_name, violation_type: violation_type, blank_count: blank_count } end i += 1 end violations end |