# All files / src/lib/quality-validator/reporters/html HtmlMetricsSection.js

0% Statements 0/207
0% Branches 0/1
0% Functions 0/1
0% Lines 0/207

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
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208

     /**
     * HTML Report Metrics Section Module
     * Generates detailed metrics display for code quality, coverage, architecture, and security
     */
    /**
     * Generate detailed metrics display section
     *
     * @param {ScoringResult} result - Complete scoring result with all metrics
     * @returns {string} HTML section with detailed metrics
     *
     * @description
     * Displays detailed metrics from all analysis categories if available
     */
    export function generateMetricsSection(result) {
        let html = '<section class="section"><h2>Detailed Metrics</h2>';
        // Get metrics from metadata (simplified approach)
        const config = result.metadata.configUsed;
        html += generateCodeQualityMetrics(config);
        html += generateTestCoverageMetrics(config);
        html += generateArchitectureMetrics(config);
        html += generateSecurityMetrics(config);
        html += '</section>';
        return html;
    }
    /**
     * Generate code quality metrics card
     *
     * @param {any} config - Configuration object
     * @returns {string} HTML code quality metrics card
     */
    function generateCodeQualityMetrics(config) {
        if (!config.codeQuality?.enabled) {
            return '';
        }
        const cq = config.codeQuality;
        return `<div class="card">
      <h3>Code Quality Configuration</h3>
      <div class="metrics-grid">
        <div class="metric">
          <div class="metric-label">Complexity Threshold</div>
          <div class="metric-value">${cq.complexity?.max || 'N/A'}</div>
        </div>
        <div class="metric">
          <div class="metric-label">Complexity Warning</div>
          <div class="metric-value">${cq.complexity?.warning || 'N/A'}</div>
        </div>
        <div class="metric">
          <div class="metric-label">Max Duplication %</div>
          <div class="metric-value">${cq.duplication?.maxPercent || 'N/A'}%</div>
        </div>
        <div class="metric">
          <div class="metric-label">Max Lint Errors</div>
          <div class="metric-value">${cq.linting?.maxErrors || 'N/A'}</div>
        </div>
      </div>
    </div>`;
    }
    /**
     * Generate test coverage metrics card
     *
     * @param {any} config - Configuration object
     * @returns {string} HTML test coverage metrics card
     */
    function generateTestCoverageMetrics(config) {
        if (!config.testCoverage?.enabled) {
            return '';
        }
        const tc = config.testCoverage;
        return `<div class="card">
      <h3>Test Coverage Configuration</h3>
      <div class="metrics-grid">
        <div class="metric">
          <div class="metric-label">Minimum Coverage</div>
          <div class="metric-value">${tc.minimumPercent || 'N/A'}%</div>
        </div>
        <div class="metric">
          <div class="metric-label">Warning Threshold</div>
          <div class="metric-value">${tc.warningPercent || 'N/A'}%</div>
        </div>
        <div class="metric">
          <div class="metric-label">Min Assertions</div>
          <div class="metric-value">${tc.effectivenessScore?.minAssertionsPerTest || 'N/A'}</div>
        </div>
        <div class="metric">
          <div class="metric-label">Max Mock Usage</div>
          <div class="metric-value">${tc.effectivenessScore?.maxMockUsagePercent || 'N/A'}%</div>
        </div>
      </div>
    </div>`;
    }
    /**
     * Generate architecture metrics card
     *
     * @param {any} config - Configuration object
     * @returns {string} HTML architecture metrics card
     */
    function generateArchitectureMetrics(config) {
        if (!config.architecture?.enabled) {
            return '';
        }
        const arch = config.architecture;
        return `<div class="card">
      <h3>Architecture Configuration</h3>
      <div class="metrics-grid">
        <div class="metric">
          <div class="metric-label">Max Component Lines</div>
          <div class="metric-value">${arch.components?.maxLines || 'N/A'}</div>
        </div>
        <div class="metric">
          <div class="metric-label">Component Warning</div>
          <div class="metric-value">${arch.components?.warningLines || 'N/A'}</div>
        </div>
        <div class="metric">
          <div class="metric-label">Atomic Design Check</div>
          <div class="metric-value">${arch.components?.validateAtomicDesign ? 'Enabled' : 'Disabled'}</div>
        </div>
        <div class="metric">
          <div class="metric-label">Pattern Check</div>
          <div class="metric-value">${arch.patterns?.enabled ? 'Enabled' : 'Disabled'}</div>
        </div>
      </div>
    </div>`;
    }
    /**
     * Generate security metrics card
     *
     * @param {any} config - Configuration object
     * @returns {string} HTML security metrics card
     */
    function generateSecurityMetrics(config) {
        if (!config.security?.enabled) {
            return '';
        }
        const sec = config.security;
        return `<div class="card">
      <h3>Security Configuration</h3>
      <div class="metrics-grid">
        <div class="metric">
          <div class="metric-label">Allow Critical Vulns</div>
          <div class="metric-value">${sec.vulnerabilities?.allowCritical || 0}</div>
        </div>
        <div class="metric">
          <div class="metric-label">Allow High Vulns</div>
          <div class="metric-value">${sec.vulnerabilities?.allowHigh || 0}</div>
        </div>
        <div class="metric">
          <div class="metric-label">Check Secrets</div>
          <div class="metric-value">${sec.patterns?.checkSecrets ? 'Yes' : 'No'}</div>
        </div>
        <div class="metric">
          <div class="metric-label">Check XSS Risks</div>
          <div class="metric-value">${sec.patterns?.checkXssRisks ? 'Yes' : 'No'}</div>
        </div>
      </div>
    </div>`;
    }
    /**
     * Generate component weight visualization
     *
     * @param {ScoringResult} result - Scoring result
     * @returns {string} HTML weight visualization card
     *
     * @description
     * Shows how each component contributes to overall score
     */
    export function generateWeightVisualization(result) {
        const weights = result.metadata.configUsed.scoring?.weights;
        if (!weights) {
            return '';
        }
        return `<section class="section">
      <h2>Scoring Weights</h2>
      <div class="card">
        <h3>Component Contribution to Overall Score</h3>
        <div class="metrics-grid">
          <div class="metric">
            <div class="metric-label">Code Quality</div>
            <div class="score-bar">
              <div class="score-fill" style="width: ${weights.codeQuality * 100}%"></div>
            </div>
            <div class="metric-value">${(weights.codeQuality * 100).toFixed(1)}%</div>
          </div>
          <div class="metric">
            <div class="metric-label">Test Coverage</div>
            <div class="score-bar">
              <div class="score-fill" style="width: ${weights.testCoverage * 100}%"></div>
            </div>
            <div class="metric-value">${(weights.testCoverage * 100).toFixed(1)}%</div>
          </div>
          <div class="metric">
            <div class="metric-label">Architecture</div>
            <div class="score-bar">
              <div class="score-fill" style="width: ${weights.architecture * 100}%"></div>
            </div>
            <div class="metric-value">${(weights.architecture * 100).toFixed(1)}%</div>
          </div>
          <div class="metric">
            <div class="metric-label">Security</div>
            <div class="score-bar">
              <div class="score-fill" style="width: ${weights.security * 100}%"></div>
            </div>
            <div class="metric-value">${(weights.security * 100).toFixed(1)}%</div>
          </div>
        </div>
      </div>
    </section>`;
    }