Class: SimpleCov::Formatter::AIFormatter::MarkdownBuilder::DeficitFormatter

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Includes:
SnippetFormatter
Defined in:
lib/simplecov-ai/markdown_builder/deficit_formatter.rb

Overview

Renders the deficits of one file as Markdown fragments, one per semantic node group.

Constant Summary collapse

ERROR_AST_FAILED =

Error message for AST parsing failures

T.let('  - **ERROR:** AST Parsing Failed. Showing raw line numbers instead.', String)
NODE_HEADING_TEMPLATE =

Template for node-level deficit headings

T.let('- %s', String)
DEFICIT_COARSE =

Coarse-grained deficit summary message

T.let('  - **Deficit:** Contains unexecuted lines or branches.', String)
LINE_DEFICIT_TMPL =

Template for a specific line deficit

T.let('  - **Line Deficit:** [L%d] %s %s', String)
BRANCH_DEFICIT_TMPL =

Template for a specific branch deficit

T.let('  - **Branch Deficit:** [L%s] Missing coverage for %s branch: %s', String)
METHOD_DEFICIT_TMPL =

Template for a method SimpleCov's method coverage reported as never invoked

T.let('  - **Method Deficit:** [L%s] %s never invoked', String)

Constants included from SnippetFormatter

SnippetFormatter::ESTIMATED_CHARS_PER_LINE, SnippetFormatter::OCCURRENCE_TEMPLATE, SnippetFormatter::TRUNCATION_ELLIPSIS

Instance Method Summary collapse

Methods included from SnippetFormatter

#build_occurrence_index, #byte_slice, #calculate_occurrence, #extract_branch_text, #extract_inline_branch, #fetch_snippet_text, #first_source_line, #line_label, #occurrence_index, #truncate_snippet

Constructor Details

#initialize(config, source_lines, branch_columns) ⇒ DeficitFormatter

Returns a new instance of DeficitFormatter.



32
33
34
35
36
# File 'lib/simplecov-ai/markdown_builder/deficit_formatter.rb', line 32

def initialize(config, source_lines, branch_columns)
  @config = config
  @source_lines = source_lines
  @branch_columns = branch_columns
end

Instance Method Details

#render_node_fragments(file, nodes, method_deficits) ⇒ Object



46
47
48
49
50
51
52
53
# File 'lib/simplecov-ai/markdown_builder/deficit_formatter.rb', line 46

def render_node_fragments(file, nodes, method_deficits)
  DeficitGrouper.build(file, nodes, method_deficits).map do |group_key, deficit_group|
    # Node-backed groups display the semantic name; the group key carries a uniqueness
    # suffix (start line) that must not appear in the report. Node-less groups fall
    # back to their positional key ("Line N" / "Lines N-M").
    render_group(deficit_group.semantic_node&.name || group_key, deficit_group)
  end
end

#render_raw_fragments(file, method_deficits) ⇒ Object



60
61
62
# File 'lib/simplecov-ai/markdown_builder/deficit_formatter.rb', line 60

def render_raw_fragments(file, method_deficits)
  [fragment([ERROR_AST_FAILED] + deficit_lines(DeficitGrouper.raw_group(file, method_deficits)))]
end