Class: Yard::Lint::Validators::Semantic::AbstractMethods::Parser

Inherits:
Parsers::Base
  • Object
show all
Defined in:
lib/yard/lint/validators/semantic/abstract_methods/parser.rb

Overview

Parser for @abstract method validation results

Instance Method Summary collapse

Methods inherited from Parsers::Base

#match

Instance Method Details

#call(yard_output) ⇒ Array<Hash>

Returns array with abstract method violation details.

Parameters:

  • yard_output (String)

    raw yard output with abstract method issues

Returns:

  • (Array<Hash>)

    array with abstract method violation details



12
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
# File 'lib/yard/lint/validators/semantic/abstract_methods/parser.rb', line 12

def call(yard_output)
  return [] if yard_output.nil? || yard_output.empty?

  lines = yard_output.split("\n").reject(&:empty?)
  results = []

  lines.each_slice(2) do |location_line, status_line|
    next unless location_line && status_line
    next unless status_line == 'has_implementation'

    # Parse location line: "file.rb:10: ClassName#method_name"
    match = location_line.match(/^(.+):(\d+): (.+)$/)
    next unless match

    file = match[1]
    line = match[2].to_i
    method_name = match[3]

    results << {
      name: 'AbstractMethod',
      method_name: method_name,
      location: file,
      line: line
    }
  end

  results
end