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
  36781569_21cd_f406_4e3c_4e1ebae94da9["formatPrComment()"]
  2707a308_9fa9_efa8_2fbd_febf984897e5["run()"]
  2707a308_9fa9_efa8_2fbd_febf984897e5 -->|calls| 36781569_21cd_f406_4e3c_4e1ebae94da9
  eb37de5e_1918_9ef8_f29d_8476d9f62be2["escapeTableCell()"]
  36781569_21cd_f406_4e3c_4e1ebae94da9 -->|calls| eb37de5e_1918_9ef8_f29d_8476d9f62be2
  style 36781569_21cd_f406_4e3c_4e1ebae94da9 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

src/dead-code.ts lines 34–85

export function formatPrComment(
  candidates: DeadCodeCandidate[],
  metadata?: DeadCodeAnalysisMetadata
): 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

Subdomains

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