@@ -48,12 +48,11 @@ func GetStatistics(path string) (statistics Statistics, err error) {
4848 }
4949
5050 var waitGroup sync.WaitGroup
51- var mutex sync.Mutex
5251
5352
5453 waitGroup .Add (1 )
5554 tree .Chdir (path ) //nolint:errcheck
56- goAroundCalculating (& waitGroup , & mutex , tree , list , & statistics , componentsSet )
55+ goAroundCalculating (& waitGroup , tree , list , & statistics , componentsSet )
5756 tree .Chdir (".." ) //nolint:errcheck
5857 waitGroup .Wait ()
5958
@@ -65,7 +64,6 @@ func GetStatistics(path string) (statistics Statistics, err error) {
6564
6665func goAroundCalculating (
6766 waitGroup * sync.WaitGroup ,
68- mutex * sync.Mutex ,
6967 tree t.Tree ,
7068 list t.Nodes ,
7169 statistics * Statistics ,
@@ -85,7 +83,7 @@ func goAroundCalculating(
8583
8684 waitGroup .Add (1 )
8785 tree .Chdir (node .Name ) //nolint:errcheck
88- go goAroundCalculating (waitGroup , mutex , tree .Copy (), newList , statistics , componentsSet .Copy ())
86+ go goAroundCalculating (waitGroup , tree .Copy (), newList , statistics , componentsSet .Copy ())
8987 tree .Chdir (".." ) //nolint:errcheck
9088
9189 if exists {
@@ -98,7 +96,6 @@ func goAroundCalculating(
9896 LOC := uint64 (1 )
9997 tree .ReadNodeLineByLine (node .Name , proceedLine , & LOC )
10098
101- mutex .Lock ()
10299 statistics .Total .Append (LOC , 1 )
103100 statistics .Languages [language ].Append (LOC , 1 )
104101
@@ -111,7 +108,6 @@ func goAroundCalculating(
111108 for componentTitle := range componentsSet .Elements {
112109 statistics .Components [componentTitle ].Append (LOC , 1 )
113110 }
114- mutex .Unlock ()
115111 }
116112 }
117113 }
@@ -120,7 +116,7 @@ func goAroundCalculating(
120116func initItems (mapping map [string ]string ) (items Items ) {
121117 items = make (Items )
122118 for _ , value := range mapping {
123- items [value ] = & TableItem {Files : 0 , LOC : 0 }
119+ items [value ] = & TableItem {Files : 0 , LOC : 0 , mutex : sync. Mutex {} }
124120 }
125121 return
126122}
0 commit comments