Home / Function/ formatPrComment() — dead-code-hunter Function Reference

formatPrComment() — dead-code-hunter Function Reference

Architecture documentation for the formatPrComment() function in dead-code.ts from the dead-code-hunter codebase.

Entity Profile

Dependency Diagram

graph TD
  2e909b04_bb6e_a3ab_d740_ab5e4292de6d["formatPrComment()"]
  917645bc_a477_1891_eaae_c95a41b4031a["run()"]
  917645bc_a477_1891_eaae_c95a41b4031a -->|calls| 2e909b04_bb6e_a3ab_d740_ab5e4292de6d
  5aa7ab2d_e5c4_b714_d886_f22469e3fda3["escapeTableCell()"]
  2e909b04_bb6e_a3ab_d740_ab5e4292de6d -->|calls| 5aa7ab2d_e5c4_b714_d886_f22469e3fda3
  style 2e909b04_bb6e_a3ab_d740_ab5e4292de6d fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

src/dead-code.ts lines 57–108

export function formatPrComment(
  candidates: DeadCodeCandidate[],
  metadata?: DeadCodeMetadata
): string {
  if (candidates.length === 0) {
    return `## Dead Code Hunter

No dead code found! Your codebase is clean.`;
  }

  const rows = candidates
    .slice(0, 50)
    .map(dc => {
      const lineInfo = dc.line ? `L${dc.line}` : '';
      const fileLink = dc.line ? `${dc.file}#L${dc.line}` : dc.file;
      const badge = dc.confidence === 'high' ? ':red_circle:' :
                    dc.confidence === 'medium' ? ':orange_circle:' : ':yellow_circle:';
      return `| \`${escapeTableCell(dc.name)}\` | ${dc.type} | ${fileLink} | ${lineInfo} | ${badge} ${dc.confidence} |`;
    })
    .join('\n');

  let comment = `## Dead Code Hunter

Found **${candidates.length}** potentially unused code element${candidates.length === 1 ? '' : 's'}:

| Name | Type | File | Line | Confidence |
|------|------|------|------|------------|
${rows}`;

  if (candidates.length > 50) {
    comment += `\n\n_...and ${candidates.length - 50} more. See action output for full list._`;
  }

  if (metadata) {
    comment += `\n\n<details><summary>Analysis summary</summary>\n\n`;
    comment += `- **Total declarations analyzed**: ${metadata.totalDeclarations}\n`;
    comment += `- **Dead code candidates**: ${metadata.deadCodeCandidates}\n`;
    comment += `- **Alive code**: ${metadata.aliveCode}\n`;
    comment += `- **Analysis method**: ${metadata.analysisMethod}\n`;
    if (metadata.transitiveDeadCount != null) {
      comment += `- **Transitive dead**: ${metadata.transitiveDeadCount}\n`;
    }
    if (metadata.symbolLevelDeadCount != null) {
      comment += `- **Symbol-level dead**: ${metadata.symbolLevelDeadCount}\n`;
    }
    comment += `\n</details>`;
  }

  comment += `\n\n---\n_Powered by [Supermodel](https://supermodeltools.com) dead code analysis_`;

  return comment;
}

Domain

Called By

Frequently Asked Questions

What does formatPrComment() do?
formatPrComment() is a function in the dead-code-hunter codebase.
What does formatPrComment() call?
formatPrComment() calls 1 function(s): escapeTableCell.
What calls formatPrComment()?
formatPrComment() is called by 1 function(s): run.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free