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

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

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

     /**
     * HTML Report Footer Module
     * Generates footer with metadata, timing information, and resources
     */
    import { formatDuration } from '../../utils/formatters.js';
    import { TOOL_METADATA } from '../../utils/constants.js';
    /**
     * Generate the HTML footer section
     *
     * @param {number} analysisTime - Analysis execution time in milliseconds
     * @param {string} toolVersion - Version of the tool
     * @returns {string} HTML footer element
     *
     * @description
     * Creates a footer containing:
     * - Analysis execution time
     * - Tool version information
     * - Metadata
     * - Generation timestamp
     */
    export function generateFooter(analysisTime, toolVersion) {
        const formattedTime = formatDuration(analysisTime);
        return `<footer class="footer">
      <p>Analysis completed in ${formattedTime} | Tool v${toolVersion}</p>
      <div class="footer-meta">
        <small>This report was generated by Quality Validator</small>
      </div>
    </footer>`;
    }
    /**
     * Generate metadata section
     *
     * @param {string} timestamp - ISO timestamp of generation
     * @param {string} projectPath - Path to analyzed project
     * @param {string} nodeVersion - Node.js version used
     * @returns {string} HTML metadata section
     *
     * @description
     * Creates a metadata display with:
     * - Generation timestamp
     * - Project path
     * - Node.js version
     * - Environment information
     */
    export function generateMetadataSection(timestamp, projectPath, nodeVersion) {
        const date = new Date(timestamp);
        const formattedDate = date.toLocaleString();
        return `<section class="section">
      <h2>Report Metadata</h2>
      <div class="metrics-grid">
        <div class="metric">
          <div class="metric-label">Generated</div>
          <div class="metric-value">${formattedDate}</div>
        </div>
        <div class="metric">
          <div class="metric-label">Project Path</div>
          <div class="metric-value"><code>${projectPath}</code></div>
        </div>
        <div class="metric">
          <div class="metric-label">Node Version</div>
          <div class="metric-value"><code>${nodeVersion}</code></div>
        </div>
        <div class="metric">
          <div class="metric-label">Tool Version</div>
          <div class="metric-value">v${TOOL_METADATA.VERSION}</div>
        </div>
      </div>
    </section>`;
    }
    /**
     * Generate script section for interactivity
     *
     * @returns {string} JavaScript code as script tag content
     *
     * @description
     * Provides:
     * - DOM ready logging
     * - Click handlers for expandable sections
     * - Print stylesheet support
     */
    export function generateScript() {
        return `
    // Report initialization
    document.addEventListener('DOMContentLoaded', function() {
      console.log('Quality Validation Report loaded');

      // Add print support
      if (window.print) {
        const printStyle = document.createElement('style');
        printStyle.textContent = '@media print { .header { page-break-after: avoid; } .section { page-break-inside: avoid; } }';
        document.head.appendChild(printStyle);
      }

      // Add collapse functionality to findings groups
      const groups = document.querySelectorAll('.findings-group');
      groups.forEach(group => {
        const title = group.querySelector('h3');
        if (title) {
          title.style.cursor = 'pointer';
          title.addEventListener('click', function() {
            const items = group.querySelectorAll('.finding');
            items.forEach(item => {
              item.style.display = item.style.display === 'none' ? 'block' : 'none';
            });
          });
        }
      });
    });
      `;
    }
    /**
     * Generate a resources/links section
     *
     * @returns {string} HTML section with helpful resources
     *
     * @description
     * Provides:
     * - Link to tool documentation
     * - Link to configuration guide
     * - Suggestion for next steps
     */
    export function generateResourcesSection() {
        return `<section class="section">
      <h2>Resources & Next Steps</h2>
      <div class="card">
        <h3>For More Information</h3>
        <ul>
          <li>Review findings and prioritize remediation efforts</li>
          <li>Follow recommendations to improve code quality</li>
          <li>Increase test coverage to improve reliability</li>
          <li>Refactor complex functions for better maintainability</li>
          <li>Address security issues immediately</li>
        </ul>

        <h3>Configuration</h3>
        <p>Create a <code>.qualityrc.json</code> file in your project root to customize quality checks.</p>

        <h3>Continuous Integration</h3>
        <p>Integrate this tool into your CI/CD pipeline to catch issues early and maintain code quality over time.</p>
      </div>
    </section>`;
    }
    /**
     * Generate legend/help section explaining report elements
     *
     * @returns {string} HTML section with legend information
     *
     * @description
     * Explains:
     * - Grading system (A-F)
     * - Severity levels
     * - Score ranges
     */
    export function generateLegendSection() {
        return `<section class="section">
      <h2>Report Legend</h2>
      <div class="card">
        <h3>Grades</h3>
        <ul>
          <li><strong>A (90-100):</strong> Excellent code quality - exceeds expectations</li>
          <li><strong>B (80-89):</strong> Good code quality - meets expectations</li>
          <li><strong>C (70-79):</strong> Acceptable code quality - areas for improvement</li>
          <li><strong>D (60-69):</strong> Poor code quality - significant issues</li>
          <li><strong>F (&lt;60):</strong> Failing code quality - critical issues</li>
        </ul>

        <h3>Finding Severity Levels</h3>
        <ul>
          <li><strong>Critical:</strong> Immediate action required - security or major issues</li>
          <li><strong>High:</strong> Should be fixed soon - significant impact on code quality</li>
          <li><strong>Medium:</strong> Should be addressed - moderate impact</li>
          <li><strong>Low:</strong> Nice to fix - minor impact</li>
          <li><strong>Info:</strong> Informational - notes and suggestions</li>
        </ul>

        <h3>Recommendation Priority</h3>
        <ul>
          <li><strong>Critical:</strong> Must implement immediately</li>
          <li><strong>High:</strong> Should implement in next sprint</li>
          <li><strong>Medium:</strong> Can be planned for later</li>
          <li><strong>Low:</strong> Nice to have improvements</li>
        </ul>
      </div>
    </section>`;
    }