Skip to content

Commit

Permalink
fix: fix concurrent map read and map write on ulocLanguageCount (#499)
Browse files Browse the repository at this point in the history
Fixes #498.
  • Loading branch information
apocelipes authored Aug 26, 2024
1 parent f0a4762 commit 5acb76c
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 52 deletions.
100 changes: 50 additions & 50 deletions SCC-OUTPUT-REPORT.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,23 @@
<tbody><tr>
<th>Go</th>
<th>30</th>
<th>9518</th>
<th>9519</th>
<th>1461</th>
<th>456</th>
<th>7601</th>
<th>7602</th>
<th>1517</th>
<th>254263</th>
<th>253980</th>
<th>4051</th>
</tr><tr>
<td>processor/formatters.go</td>
<td></td>
<td>1605</td>
<td>1606</td>
<td>208</td>
<td>43</td>
<td>1354</td>
<td>1355</td>
<td>289</td>
<td>48017</td>
<td>793</td>
<td>48000</td>
<td>794</td>
</tr><tr>
<td>processor/workers_test.go</td>
<td></td>
Expand All @@ -38,7 +38,7 @@
<td>33</td>
<td>1257</td>
<td>287</td>
<td>32306</td>
<td>32293</td>
<td>525</td>
</tr><tr>
<td>processor/formatters_test.go</td>
Expand All @@ -48,7 +48,7 @@
<td>3</td>
<td>1304</td>
<td>120</td>
<td>34187</td>
<td>34174</td>
<td>385</td>
</tr><tr>
<td>processor/workers.go</td>
Expand All @@ -58,7 +58,7 @@
<td>91</td>
<td>654</td>
<td>226</td>
<td>25549</td>
<td>25536</td>
<td>495</td>
</tr><tr>
<td>processor/processor.go</td>
Expand All @@ -68,7 +68,7 @@
<td>103</td>
<td>424</td>
<td>92</td>
<td>19301</td>
<td>19295</td>
<td>435</td>
</tr><tr>
<td>main.go</td>
Expand All @@ -78,7 +78,7 @@
<td>6</td>
<td>382</td>
<td>10</td>
<td>8869</td>
<td>8856</td>
<td>253</td>
</tr><tr>
<td>processor/detector_test.go</td>
Expand All @@ -88,7 +88,7 @@
<td>2</td>
<td>304</td>
<td>101</td>
<td>7271</td>
<td>7258</td>
<td>149</td>
</tr><tr>
<td>cmd/badges/main.go</td>
Expand All @@ -108,7 +108,7 @@
<td>2</td>
<td>210</td>
<td>40</td>
<td>4040</td>
<td>4027</td>
<td>125</td>
</tr><tr>
<td>processor/detector.go</td>
Expand All @@ -118,7 +118,7 @@
<td>33</td>
<td>159</td>
<td>57</td>
<td>6245</td>
<td>6232</td>
<td>151</td>
</tr><tr>
<td>processor/file_test.go</td>
Expand All @@ -128,7 +128,7 @@
<td>1</td>
<td>162</td>
<td>37</td>
<td>4598</td>
<td>4585</td>
<td>97</td>
</tr><tr>
<td>processor/structs.go</td>
Expand All @@ -138,7 +138,7 @@
<td>18</td>
<td>160</td>
<td>17</td>
<td>5896</td>
<td>5883</td>
<td>139</td>
</tr><tr>
<td>processor/workers_regression_test.go</td>
Expand All @@ -148,7 +148,7 @@
<td>5</td>
<td>146</td>
<td>40</td>
<td>3415</td>
<td>3402</td>
<td>93</td>
</tr><tr>
<td>processor/file.go</td>
Expand All @@ -158,7 +158,7 @@
<td>16</td>
<td>127</td>
<td>50</td>
<td>3779</td>
<td>3766</td>
<td>99</td>
</tr><tr>
<td>processor/processor_test.go</td>
Expand All @@ -168,7 +168,7 @@
<td>1</td>
<td>114</td>
<td>21</td>
<td>2586</td>
<td>2573</td>
<td>66</td>
</tr><tr>
<td>cmd/badges/main_test.go</td>
Expand Down Expand Up @@ -198,7 +198,7 @@
<td>1</td>
<td>84</td>
<td>10</td>
<td>1995</td>
<td>1982</td>
<td>57</td>
</tr><tr>
<td>scripts/include.go</td>
Expand All @@ -218,18 +218,8 @@
<td>14</td>
<td>41</td>
<td>8</td>
<td>2043</td>
<td>2030</td>
<td>52</td>
</tr><tr>
<td>processor/filereader.go</td>
<td></td>
<td>52</td>
<td>10</td>
<td>10</td>
<td>32</td>
<td>6</td>
<td>1329</td>
<td>37</td>
</tr><tr>
<td>cmd/badges/simplecache_test.go</td>
<td></td>
Expand All @@ -240,6 +230,16 @@
<td>9</td>
<td>1041</td>
<td>30</td>
</tr><tr>
<td>processor/filereader.go</td>
<td></td>
<td>52</td>
<td>10</td>
<td>10</td>
<td>32</td>
<td>6</td>
<td>1316</td>
<td>37</td>
</tr><tr>
<td>processor/cocomo.go</td>
<td></td>
Expand All @@ -248,18 +248,8 @@
<td>18</td>
<td>19</td>
<td>0</td>
<td>2222</td>
<td>2209</td>
<td>35</td>
</tr><tr>
<td>processor/cocomo_test.go</td>
<td></td>
<td>37</td>
<td>8</td>
<td>4</td>
<td>25</td>
<td>6</td>
<td>699</td>
<td>23</td>
</tr><tr>
<td>processor/bloom.go</td>
<td></td>
Expand All @@ -270,6 +260,16 @@
<td>2</td>
<td>1062</td>
<td>29</td>
</tr><tr>
<td>processor/cocomo_test.go</td>
<td></td>
<td>37</td>
<td>8</td>
<td>4</td>
<td>25</td>
<td>6</td>
<td>686</td>
<td>23</td>
</tr><tr>
<td>processor/helpers_test.go</td>
<td></td>
Expand All @@ -278,7 +278,7 @@
<td>1</td>
<td>19</td>
<td>4</td>
<td>447</td>
<td>434</td>
<td>18</td>
</tr><tr>
<td>processor/processor_unix_test.go</td>
Expand All @@ -288,7 +288,7 @@
<td>3</td>
<td>15</td>
<td>0</td>
<td>424</td>
<td>411</td>
<td>16</td>
</tr><tr>
<td>examples/language/go.go</td>
Expand All @@ -308,7 +308,7 @@
<td>4</td>
<td>10</td>
<td>0</td>
<td>391</td>
<td>378</td>
<td>14</td>
</tr><tr>
<td>processor/constants.go</td>
Expand All @@ -324,15 +324,15 @@
<tfoot><tr>
<th>Total</th>
<th>30</th>
<th>9518</th>
<th>9519</th>
<th>1461</th>
<th>456</th>
<th>7601</th>
<th>7602</th>
<th>1517</th>
<th>254263</th>
<th>253980</th>
<th>4051</th>
</tr>
<tr>
<th colspan="9">Estimated Cost to Develop (organic) $227,252<br>Estimated Schedule Effort (organic) 7.83 months<br>Estimated People Required (organic) 2.58<br></th>
<th colspan="9">Estimated Cost to Develop (organic) $227,284<br>Estimated Schedule Effort (organic) 7.83 months<br>Estimated People Required (organic) 2.58<br></th>
</tr></tfoot>
</table></body></html>
5 changes: 3 additions & 2 deletions processor/formatters.go
Original file line number Diff line number Diff line change
Expand Up @@ -1463,7 +1463,7 @@ func aggregateLanguageSummary(input chan *FileJob) []LanguageSummary {
Count: 1,
Files: files,
Bytes: res.Bytes,
ULOC: len(ulocLanguageCount[res.Language]),
ULOC: 0,
}
} else {
tmp := langs[res.Language]
Expand All @@ -1482,13 +1482,14 @@ func aggregateLanguageSummary(input chan *FileJob) []LanguageSummary {
Count: tmp.Count + 1,
Files: files,
Bytes: res.Bytes + tmp.Bytes,
ULOC: len(ulocLanguageCount[res.Language]),
ULOC: 0,
}
}
}

language := make([]LanguageSummary, 0, len(langs))
for _, summary := range langs {
summary.ULOC = len(ulocLanguageCount[summary.Name]) // for #498
language = append(language, summary)
}

Expand Down

0 comments on commit 5acb76c

Please sign in to comment.