All files / src provider.ts

100% Statements 9/9
50% Branches 1/2
100% Functions 5/5
100% Lines 8/8

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                          2x           1x     1x     1x     1x 1x 1x   1x              
import {
  AnalysisResult,
  createProvider,
  ToolName,
  ScanOptions,
} from '@aiready/core';
import { analyzeConsistency } from './analyzer';
import { calculateConsistencyScore } from './scoring';
import { ConsistencyOptions, ConsistencyIssue } from './types';
 
/**
 * Consistency Tool Provider
 */
export const ConsistencyProvider = createProvider({
  id: ToolName.NamingConsistency,
  alias: ['consistency', 'naming', 'standards'],
  version: '0.16.5',
  defaultWeight: 14,
  async analyzeReport(options: ScanOptions) {
    return analyzeConsistency(options as ConsistencyOptions);
  },
  getResults(report) {
    return report.results as AnalysisResult[];
  },
  getSummary(report) {
    return report.summary;
  },
  score(output, options) {
    const results = output.results as AnalysisResult[];
    const allIssues = results.flatMap((r) => r.issues as ConsistencyIssue[]);
    const totalFiles = (output.summary as any).filesAnalyzed || results.length;
 
    return calculateConsistencyScore(
      allIssues,
      totalFiles,
      (options as any).costConfig
    );
  },
});