Class: SimpleCov::Formatter::AIFormatter::MarkdownBuilder::DeficitCompiler

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

Overview

Iterates through files with coverage deficits and coordinates their AST parsing and snippet generation.

Constant Summary collapse

HEADING =

Header for the coverage deficits section

T.let("## Coverage Deficits\n\n", String)
FILE_HEADING_TEMPLATE =

Template for file-level deficit headings

T.let('### `%s`', String)
ERROR_AST_FAILED =

Error message for AST parsing failures

T.let("  - **ERROR:** AST Parsing Failed. Showing raw line numbers instead.\n", 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_TEMPLATE =

Template for a specific line deficit

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

Template for a specific branch deficit

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

Constants included from SnippetFormatter

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

Instance Method Summary collapse

Methods included from SnippetFormatter

#calculate_occurrence, #count_snippet_occurrences, #fetch_snippet_text, #truncate_snippet

Constructor Details

#initialize(coverage_metrics, config, builder) ⇒ DeficitCompiler

Returns a new instance of DeficitCompiler.



30
31
32
33
34
# File 'lib/simplecov-ai/markdown_builder/deficit_compiler.rb', line 30

def initialize(coverage_metrics, config, builder)
  @coverage_metrics = coverage_metrics
  @config = config
  @builder = builder
end

Instance Method Details

#write_deficits(buffer) ⇒ Object



37
38
39
40
41
42
43
44
45
46
47
# File 'lib/simplecov-ai/markdown_builder/deficit_compiler.rb', line 37

def write_deficits(buffer)
  files = find_deficit_files
  return if files.empty?

  buffer.puts HEADING
  files.each do |file|
    break if @builder.truncate_if_needed?

    process_file(buffer, file)
  end
end