UNPKG

agentsqripts

Version:

Comprehensive static code analysis toolkit for identifying technical debt, security vulnerabilities, performance issues, and code quality problems

79 lines (70 loc) 1.81 kB
/** * @file Grade calculation utilities index * @description Single responsibility: Export all grade calculation utilities */ const scoreToGrade = require('./scoreToGrade'); /** * Convert grade to emoji * @param {string} grade - Letter grade * @returns {string} Emoji representation */ function gradeToEmoji(grade) { const emojiMap = { 'A': '🅰️', 'B': '🅱️', 'C': '🟡', 'D': '🟠', 'F': '🔴' }; return emojiMap[grade] || '❓'; } /** * Calculate grade from number of issues * @param {number} issueCount - Number of issues found * @param {number} totalFiles - Total files analyzed * @returns {string} Letter grade */ function calculateGradeFromIssues(issueCount, totalFiles = 1) { if (totalFiles === 0) return 'F'; const issuesPerFile = issueCount / totalFiles; if (issuesPerFile === 0) return 'A'; if (issuesPerFile <= 1) return 'B'; if (issuesPerFile <= 3) return 'C'; if (issuesPerFile <= 5) return 'D'; return 'F'; } /** * Get color for grade display * @param {string} grade - Letter grade * @returns {string} Color name or hex code */ function getGradeColor(grade) { const colorMap = { 'A': 'green', 'B': 'lightgreen', 'C': 'yellow', 'D': 'orange', 'F': 'red' }; return colorMap[grade] || 'gray'; } /** * Format grade display with emoji and color * @param {string} grade - Letter grade * @param {boolean} includeEmoji - Include emoji in display * @returns {string} Formatted grade display */ function formatGradeDisplay(grade, includeEmoji = true) { if (includeEmoji === false) { return grade; } const emoji = gradeToEmoji(grade); return `${emoji} ${grade}`; } module.exports = { scoreToGrade, gradeToEmoji, calculateGradeFromIssues, getGradeColor, formatGradeDisplay };