Class: Yard::Lint::Validators::Documentation::UnderfilledLines::Parser
- Inherits:
-
Parsers::Base
- Object
- Parsers::Base
- Yard::Lint::Validators::Documentation::UnderfilledLines::Parser
- Defined in:
- lib/yard/lint/validators/documentation/underfilled_lines/parser.rb
Overview
Parses UnderfilledLines validator output into structured violation hashes.
Expected format (two lines per object with violations):
file.rb:OBJECT_LINE: ObjectName
MAX_LENGTH|START:ACTUAL:REFLOW:WIDEST|START:ACTUAL:REFLOW:WIDEST|...
Instance Method Summary collapse
-
#call(output) ⇒ Array<Hash>
Array of violation hashes.
Methods inherited from Parsers::Base
Instance Method Details
#call(output) ⇒ Array<Hash>
Returns array of violation hashes.
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 54 55 56 57 58 |
# File 'lib/yard/lint/validators/documentation/underfilled_lines/parser.rb', line 16 def call(output, **) return [] if output.nil? || output.empty? violations = [] lines = output.lines.map(&:chomp) i = 0 while i < lines.size location_match = lines[i].match(/^(.+):(\d+): (.+)$/) if location_match file_path = location_match[1] object_line = location_match[2].to_i object_name = location_match[3] i += 1 if i < lines.size parts = lines[i].split('|') max_length = parts.shift.to_i parts.each do |part| start, actual, reflow, widest = part.split(':', 4) next unless start && actual && reflow && widest violations << { location: file_path, line: start.to_i, object_line: object_line, object_name: object_name, actual_lines: actual.to_i, reflowed_lines: reflow.to_i, widest_fill: widest.to_i, max_length: max_length } end end end i += 1 end violations end |