All files / scripts/agentic/gate-checks no-stubs.ts

100% Statements 11/11
100% Branches 4/4
100% Functions 1/1
100% Lines 11/11

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 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 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56                                                    8x   8x   8x 100x 100x 100x 400x 6x                   8x 4x             8x    
/**
 * @module scripts/agentic/gate-checks/no-stubs
 * @description Check 3 — No stub placeholders (recursive scan).
 *
 * Scans all markdown files under the analysis directory (recursive,
 * including `documents/` and `pass1/` subdirs) for stub placeholder
 * strings. The canonical gate uses a recursive grep over the entire
 * `$ANALYSIS_DIR`.
 *
 * @see .github/prompts/05-analysis-gate.md §Check 3
 * @author Hack23 AB
 * @license Apache-2.0
 */
 
import { readFile } from 'node:fs/promises';
import { join } from 'node:path';
 
import { STUB_PLACEHOLDERS } from '../artifact-inventory.js';
import { collectMdFilesRecursive } from '../gate-shared/file-walkers.js';
import type { GateCheckResult } from '../gate-shared/types.js';
 
/**
 * Scan all markdown files under the analysis directory for stub
 * placeholder strings.
 */
export async function checkNoStubs(analysisDir: string): Promise<GateCheckResult[]> {
  const results: GateCheckResult[] = [];
 
  const mdFiles = await collectMdFilesRecursive(analysisDir, '');
 
  for (const relPath of mdFiles) {
    const filePath = join(analysisDir, relPath);
    const content = await readFile(filePath, 'utf-8');
    for (const stub of STUB_PLACEHOLDERS) {
      if (content.includes(stub)) {
        results.push({
          checkId: 'no-stubs',
          passed: false,
          message: `Stub placeholder "${stub}" found in ${relPath}`,
          artifact: relPath,
        });
      }
    }
  }
 
  if (results.length === 0) {
    results.push({
      checkId: 'no-stubs',
      passed: true,
      message: 'No stub placeholders detected',
    });
  }
 
  return results;
}