vibe-janitor
Version:
A CLI tool that cleans AI-generated JavaScript/TypeScript projects efficiently and intelligently
89 lines (88 loc) • 2 kB
TypeScript
/**
* Interface for complexity metrics of a file
*/
export interface FileComplexity {
filePath: string;
lineCount: number;
functionCount: number;
longFunctions: {
name: string;
lineCount: number;
}[];
deepNesting: {
location: string;
depth: number;
}[];
complexity: number;
}
/**
* Options for code analysis
*/
export interface AnalyzerOptions {
maxLineCount?: number;
maxFunctionLength?: number;
maxNestingDepth?: number;
verbose?: boolean;
}
/**
* Results from the analysis process
*/
export interface AnalysisResult {
largeFiles: FileComplexity[];
complexFunctions: {
filePath: string;
functions: {
name: string;
lineCount: number;
}[];
}[];
deeplyNested: {
filePath: string;
locations: {
location: string;
depth: number;
}[];
}[];
circularDependencies: string[][];
}
/**
* Analyzes code complexity and structure
*/
export declare class Analyzer {
private project;
private targetDir;
private options;
constructor(targetDir: string, options?: AnalyzerOptions);
/**
* Finds the TypeScript config file for the target directory
*/
private findTsConfig;
/**
* Add files to the project for analysis
*/
private addFilesToProject;
/**
* Calculate complexity metrics for a source file
*/
private calculateFileComplexity;
/**
* Find large files based on line count
*/
private findLargeFiles;
/**
* Find complex functions
*/
private findComplexFunctions;
/**
* Find deeply nested code
*/
private findDeeplyNestedCode;
/**
* Find circular dependencies (placeholder - would use madge in a full implementation)
*/
private findCircularDependencies;
/**
* Run the analysis process on the target directory
*/
analyze(): Promise<AnalysisResult>;
}