@@ -9,6 +9,7 @@ export type ChangeCouplingResult = {
99 matrix : number [ ] [ ] ;
1010 dimensions : string [ ] ;
1111 groups : string [ ] ;
12+ sumOfCoupling : number [ ] ;
1213
1314 fileCount : number [ ] ;
1415 cohesion : number [ ] ;
@@ -26,6 +27,7 @@ export async function calcChangeCoupling(
2627 const matrix = getEmptyMatrix ( modules . length ) ;
2728
2829 const commitsPerModule : number [ ] = new Array ( matrix . length ) . fill ( 0 ) ;
30+ const sumOfCoupling : number [ ] = new Array ( matrix . length ) . fill ( 0 ) ;
2931
3032 const parseOptions : ParseOptions = {
3133 limits,
@@ -43,19 +45,34 @@ export async function calcChangeCoupling(
4345 }
4446 }
4547 }
48+
49+ updateSumOfCoupling ( touchedModules , sumOfCoupling ) ;
4650 addToMatrix ( touchedModules , matrix ) ;
4751 } , parseOptions ) ;
4852
4953 return {
5054 matrix,
5155 dimensions : displayModules ,
5256 groups : config . groups ,
53-
57+ sumOfCoupling ,
5458 fileCount : commitsPerModule ,
5559 cohesion : new Array ( matrix . length ) . fill ( - 1 ) ,
5660 } ;
5761}
5862
63+ function updateSumOfCoupling (
64+ touchedModules : Set < number > ,
65+ sumOfCoupling : number [ ]
66+ ) {
67+ const count = touchedModules . size ;
68+ if ( count > 1 ) {
69+ const otherModules = count - 1 ;
70+ for ( const module of touchedModules ) {
71+ sumOfCoupling [ module ] += otherModules ;
72+ }
73+ }
74+ }
75+
5976function addToMatrix ( touchedModules : Set < number > , matrix : number [ ] [ ] ) {
6077 const touchedArray = Array . from ( touchedModules ) ;
6178 for ( const module1 of touchedArray ) {
0 commit comments