arela
Version:
AI-powered CTO with multi-agent orchestration, code summarization, visual testing (web + mobile) for blazing fast development.
50 lines • 1.53 kB
TypeScript
/**
* Coupling calculator - measures cross-layer/cross-module dependencies
* Lower coupling is better (less tightly coupled)
*/
import { DirectoryAnalysis } from "./types.js";
export interface CouplingAnalysis {
totalImports: number;
crossDirectoryImports: number;
crossLayerImports: number;
coupling: number;
details: CouplingDetail[];
}
export interface CouplingDetail {
from: string;
to: string;
count: number;
isLayerViolation: boolean;
}
/**
* Calculate coupling score from imports
*
* Algorithm:
* 1. Count all imports in the codebase
* 2. Identify cross-directory imports (dependencies between different dirs)
* 3. For horizontal architectures, check if imports cross layers
* 4. Score = (crossLayerImports / totalImports) * 100
*
* Score scale:
* 0-20: Excellent (very loosely coupled)
* 21-40: Good (loosely coupled)
* 41-60: Fair (moderately coupled)
* 61-80: Poor (tightly coupled)
* 81-100: Critical (very tightly coupled)
*/
export declare function calculateCoupling(imports: Array<{
from: string;
to: string | null;
fromDir: string;
toDir?: string;
}>, directories: Map<string, DirectoryAnalysis>): CouplingAnalysis;
/**
* Analyze import patterns and detect problematic dependencies
*/
export declare function detectCouplingIssues(analysis: CouplingAnalysis, directories: Map<string, DirectoryAnalysis>): Array<{
severity: 'critical' | 'warning';
message: string;
from: string;
to: string;
}>;
//# sourceMappingURL=coupling.d.ts.map