UNPKG

ds-sfcoe-ailabs

Version:

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

81 lines (80 loc) 2.54 kB
import { Log } from 'sarif'; /** * Abstract base class for Static Code Analysis Tool (SCAT) providers * Provides common functionality for code analysis tools that generate SARIF output */ export default abstract class SCATProvider { private readonly scanDirectory; private readonly configFile; private readonly sarifFileName; /** * Creates a new SCAT provider instance * * @param scanDirectory - The directory to scan for code analysis * @param configFile - The configuration file path for the analyzer * @param sarifFileName - Optional custom SARIF output file name * @throws Error if scanDirectory or configFile are invalid * @example * ```typescript * class CustomSCATProvider extends SCATProvider { * constructor() { * super('/scan/dir', 'config.xml', 'custom.sarif'); * } * } * ``` */ constructor(scanDirectory: string, configFile: string, sarifFileName?: string); /** * Reads and parses the SARIF results file * * @returns Promise that resolves to the parsed SARIF log * @throws Error if SARIF file cannot be read or parsed * @example * ```typescript * const sarifLog = await this.getSarifFile(); * console.log(sarifLog.runs); * ``` */ protected getSarifFile(): Promise<Log>; /** * Gets the SARIF output file name * * @returns The SARIF file name */ protected getSarifFileName(): string; /** * Gets the configuration file path * * @returns The configuration file path * @example * ```typescript * const configPath = this.getConfigFile(); * console.log(configPath); // '/path/to/config.xml' * ``` */ protected getConfigFile(): string; /** * Gets the scan directory path * * @returns The scan directory path * @example * ```typescript * const scanDir = this.getScanDirectory(); * console.log(scanDir); // '/path/to/scan' * ``` */ protected getScanDirectory(): string; /** * Runs the static code analysis tool * * @param scanDirectory - Optional override for the scan directory * @returns Promise that resolves to the SARIF analysis results * @throws Error if the analysis tool execution fails * @example * ```typescript * const results = await provider.run('/custom/scan/dir'); * console.log(results.runs); * ``` */ abstract run(scanDirectory?: string): Promise<Log>; }