UNPKG

ds-sfcoe-ailabs

Version:

AI-powered code review tool with static analysis integration for comprehensive code quality assessment.

126 lines (125 loc) 4.59 kB
import { ReviewHint } from '../aiProvider/index.js'; import { TableEntry } from './index.js'; /** * Utility class for creating and managing table entries * * Provides methods for converting review hints into table entries, * creating custom table entries, and managing entry collections * to avoid duplicates in analysis results. * * @example * ```typescript * const entry = TableEntryUtils.createTableEntryFromHint( * 'MyClass.cls', * { * ruleId: 'ApexBestPractices', * message: 'Method should be static', * region: { startLine: 25 } * } * ); * ``` */ export declare class TableEntryUtils { /** * Create a table entry from a review hint * * @param fileName - The name of the file being processed * @param hint - The review hint containing violation information * @returns A formatted table entry with extracted information * @example * ```typescript * const entry = TableEntryUtils.createTableEntryFromHint( * 'src/MyClass.cls', * { * ruleId: 'ApexComplexity', * message: 'Method complexity too high', * region: { startLine: 42 } * } * ); * // Returns: { className: 'MyClass.cls', lineNumber: 42, ... } * ``` */ static createTableEntryFromHint(fileName: string, hint: ReviewHint): TableEntry; /** * Create a custom table entry * * @param fileName - The name of the file being processed * @param lineNumber - The line number where the issue occurs * @param ruleType - The category/type of the rule violation * @param issue - Description of the issue found * @param suggestedFix - Suggested fix for the issue * @returns A formatted table entry with the provided information * @example * ```typescript * const entry = TableEntryUtils.createCustomTableEntry( * 'src/Helper.cls', * 15, * 'Performance', * 'Inefficient query detected', * 'Use selective SOQL with WHERE clause' * ); * ``` */ static createCustomTableEntry(fileName: string, lineNumber: number, ruleType: string, issue: string, suggestedFix: string): TableEntry; /** * Check if entry should be added (not already in set) * * @param entryKey - The unique key for the entry * @param addedEntries - Set of already processed entry keys * @returns True if the entry should be added, false if it already exists * @example * ```typescript * const addedEntries = new Set<string>(); * const shouldAdd = TableEntryUtils.shouldAddEntry( * 'MyClass.cls:ApexComplexity:42', * addedEntries * ); * console.log(shouldAdd); // true (first time) * ``` */ static shouldAddEntry(entryKey: string, addedEntries: Set<string>): boolean; /** * Add entry to collection if not already present * * @param entries - Array of table entries to add to * @param entry - The table entry to potentially add * @param entryKey - The unique key for the entry * @param addedEntries - Set of already processed entry keys * @returns True if the entry was added, false if it already existed * @example * ```typescript * const entries: TableEntry[] = []; * const addedEntries = new Set<string>(); * const wasAdded = TableEntryUtils.addEntryIfNotExists( * entries, * newEntry, * 'MyClass.cls:Rule:25', * addedEntries * ); * ``` */ static addEntryIfNotExists(entries: TableEntry[], entry: TableEntry, entryKey: string, addedEntries: Set<string>): boolean; /** * Batch create table entries from multiple hints * * @param fileName - The name of the file being processed * @param hints - Array of review hints to convert to table entries * @param addedEntries - Set of already processed entry keys to avoid duplicates * @returns Array of table entries created from the hints * @example * ```typescript * const hints = [ * { ruleId: 'Rule1', message: 'Issue 1', region: { startLine: 10 } }, * { ruleId: 'Rule2', message: 'Issue 2', region: { startLine: 20 } } * ]; * const addedEntries = new Set<string>(); * const entries = TableEntryUtils.createTableEntriesFromHints( * 'MyClass.cls', * hints, * addedEntries * ); * console.log(entries.length); // 2 (if no duplicates) * ``` */ static createTableEntriesFromHints(fileName: string, hints: ReviewHint[], addedEntries: Set<string>): TableEntry[]; }