UNPKG

dependency-cruiser

Version:

Validate and visualize dependencies. With your rules. JavaScript, TypeScript, CoffeeScript. ES6, CommonJS, AMD.

29 lines (27 loc) 786 B
export function metricsAreCalculable(pModule) { return ( !pModule.coreModule && !pModule.couldNotResolve && !pModule.matchesDoNotFollow ); } /** * returns the Instability of a component given the number of incoming (afferent) * and outgoing (efferent) connections ('couplings') * * @param {number} pEfferentCouplingCount * @param {number} pAfferentCouplingCount * @returns number */ export function calculateInstability( pEfferentCouplingCount, pAfferentCouplingCount, ) { // when both afferentCouplings and efferentCouplings equal 0 instability will // yield NaN. Judging Bob Martin's intention, a component with no outgoing // dependencies is maximum stable (0) return ( pEfferentCouplingCount / (pEfferentCouplingCount + pAfferentCouplingCount) || 0 ); }