All files scoring.ts

100% Statements 5/5
100% Branches 4/4
100% Functions 2/2
100% Lines 4/4

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                    2x   2x                       2x           2x                        
import { ToolName } from '@aiready/core';
import type { ToolScoringOutput } from '@aiready/core';
import type { ChangeAmplificationReport } from './types';
 
/**
 * Convert change amplification report into a ToolScoringOutput.
 */
export function calculateChangeAmplificationScore(
  report: ChangeAmplificationReport
): ToolScoringOutput {
  const { summary } = report;
 
  const factors: ToolScoringOutput['factors'] = [
    {
      name: 'Graph Stability',
      impact: Math.round(summary.score - 50),
      description:
        summary.score < 30
          ? 'High coupling detected in core modules'
          : 'Stable dependency structure',
    },
  ];
 
  const recommendations: ToolScoringOutput['recommendations'] =
    summary.recommendations.map((rec) => ({
      action: rec,
      estimatedImpact: 10,
      priority: summary.score < 50 ? 'high' : 'medium',
    }));
 
  return {
    toolName: ToolName.ChangeAmplification,
    score: summary.score,
    rawMetrics: {
      totalFiles: summary.totalFiles,
      totalIssues: summary.totalIssues,
      rating: summary.rating,
    },
    factors,
    recommendations,
  };
}