Skip to content

Commit d6c7e02

Browse files
committed
fixes a few edge cases
1 parent 925f69b commit d6c7e02

4 files changed

Lines changed: 161 additions & 44 deletions

File tree

SCC-OUTPUT-REPORT.html

Lines changed: 54 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -12,23 +12,23 @@
1212
</tr></thead>
1313
<tbody><tr>
1414
<th>Go</th>
15-
<th>67</th>
16-
<th>39715</th>
17-
<th>2972</th>
18-
<th>1994</th>
19-
<th>34749</th>
20-
<th>4365</th>
21-
<th>948536</th>
22-
<th>14405</th>
15+
<th>68</th>
16+
<th>39810</th>
17+
<th>3011</th>
18+
<th>2064</th>
19+
<th>34735</th>
20+
<th>4413</th>
21+
<th>950794</th>
22+
<th>14433</th>
2323
</tr><tr>
2424
<td>processor/constants.go</td>
2525
<td></td>
26-
<td>14855</td>
26+
<td>14873</td>
2727
<td>1</td>
2828
<td>2</td>
29-
<td>14852</td>
29+
<td>14870</td>
3030
<td>0</td>
31-
<td>239226</td>
31+
<td>239547</td>
3232
<td>2280</td>
3333
</tr><tr>
3434
<td>processor/workers_test.go</td>
@@ -174,10 +174,10 @@
174174
<td>config.go</td>
175175
<td></td>
176176
<td>585</td>
177-
<td>24</td>
178-
<td>49</td>
179-
<td>512</td>
180-
<td>41</td>
177+
<td>51</td>
178+
<td>111</td>
179+
<td>423</td>
180+
<td>77</td>
181181
<td>27979</td>
182182
<td>421</td>
183183
</tr><tr>
@@ -250,16 +250,6 @@
250250
<td>52</td>
251251
<td>10674</td>
252252
<td>281</td>
253-
</tr><tr>
254-
<td>processor/file_test.go</td>
255-
<td></td>
256-
<td>373</td>
257-
<td>70</td>
258-
<td>16</td>
259-
<td>287</td>
260-
<td>75</td>
261-
<td>8978</td>
262-
<td>178</td>
263253
</tr><tr>
264254
<td>processor/history_languages.go</td>
265255
<td></td>
@@ -270,6 +260,16 @@
270260
<td>52</td>
271261
<td>10482</td>
272262
<td>269</td>
263+
</tr><tr>
264+
<td>processor/file_test.go</td>
265+
<td></td>
266+
<td>373</td>
267+
<td>70</td>
268+
<td>16</td>
269+
<td>287</td>
270+
<td>75</td>
271+
<td>8978</td>
272+
<td>178</td>
273273
</tr><tr>
274274
<td>processor/formatters_misc.go</td>
275275
<td></td>
@@ -290,16 +290,6 @@
290290
<td>59</td>
291291
<td>8670</td>
292292
<td>225</td>
293-
</tr><tr>
294-
<td>processor/formatters.go</td>
295-
<td></td>
296-
<td>304</td>
297-
<td>31</td>
298-
<td>11</td>
299-
<td>262</td>
300-
<td>44</td>
301-
<td>8599</td>
302-
<td>178</td>
303293
</tr><tr>
304294
<td>cmd/badges/main_test.go</td>
305295
<td></td>
@@ -310,6 +300,16 @@
310300
<td>13</td>
311301
<td>7909</td>
312302
<td>177</td>
303+
</tr><tr>
304+
<td>processor/formatters.go</td>
305+
<td></td>
306+
<td>304</td>
307+
<td>31</td>
308+
<td>11</td>
309+
<td>262</td>
310+
<td>44</td>
311+
<td>8599</td>
312+
<td>178</td>
313313
</tr><tr>
314314
<td>processor/processor_test.go</td>
315315
<td></td>
@@ -600,6 +600,16 @@
600600
<td>13</td>
601601
<td>2123</td>
602602
<td>62</td>
603+
</tr><tr>
604+
<td>processor/workers_charliteral_test.go</td>
605+
<td></td>
606+
<td>77</td>
607+
<td>12</td>
608+
<td>8</td>
609+
<td>57</td>
610+
<td>12</td>
611+
<td>1937</td>
612+
<td>42</td>
603613
</tr><tr>
604614
<td>processor/workers_issue175_test.go</td>
605615
<td></td>
@@ -693,16 +703,16 @@
693703
</tr></tbody>
694704
<tfoot><tr>
695705
<th>Total</th>
696-
<th>67</th>
697-
<th>39715</th>
698-
<th>2972</th>
699-
<th>1994</th>
700-
<th>34749</th>
701-
<th>4365</th>
702-
<th>948536</th>
703-
<th>14405</th>
706+
<th>68</th>
707+
<th>39810</th>
708+
<th>3011</th>
709+
<th>2064</th>
710+
<th>34735</th>
711+
<th>4413</th>
712+
<th>950794</th>
713+
<th>14433</th>
704714
</tr>
705715
<tr>
706-
<th colspan="9">Estimated Cost to Develop (organic) $1,120,946<br>Estimated Schedule Effort (organic) 14.36 months<br>Estimated People Required (organic) 6.93<br></th>
716+
<th colspan="9">Estimated Cost to Develop (organic) $1,120,471<br>Estimated Schedule Effort (organic) 14.36 months<br>Estimated People Required (organic) 6.93<br></th>
707717
</tr></tfoot>
708718
</table></body></html>

languages.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1012,6 +1012,10 @@
10121012
{
10131013
"end": "\"",
10141014
"start": "\""
1015+
},
1016+
{
1017+
"end": "'",
1018+
"start": "'"
10151019
}
10161020
],
10171021
"shebangs": ["dotnet"]
@@ -2920,6 +2924,10 @@
29202924
"end": "`",
29212925
"ignoreEscape": true,
29222926
"start": "`"
2927+
},
2928+
{
2929+
"end": "'",
2930+
"start": "'"
29232931
}
29242932
]
29252933
},
@@ -3686,6 +3694,10 @@
36863694
{
36873695
"end": "\"",
36883696
"start": "\""
3697+
},
3698+
{
3699+
"end": "'",
3700+
"start": "'"
36893701
}
36903702
]
36913703
},

processor/constants.go

Lines changed: 18 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
// SPDX-License-Identifier: MIT
2+
3+
package processor
4+
5+
import (
6+
"testing"
7+
)
8+
9+
// Follow-up to https://github.com/boyter/scc/issues/175 (dwmcrobb's comment):
10+
// a character/rune literal containing a double quote, e.g. '"', was not modelled
11+
// as a string, so the embedded " opened a phantom string that swallowed the
12+
// comment which followed. Languages where ' is unambiguously a char/rune literal
13+
// (no ' digit separator, no lifetime/quote meaning) get a plain ' -> ' quote.
14+
// C and C++ are deliberately excluded for now because ' is also a digit
15+
// separator there (1'000'000) and needs disambiguation.
16+
17+
func TestCountStatsCharLiteralGo(t *testing.T) {
18+
ProcessConstants()
19+
fileJob := FileJob{Language: "Go"}
20+
fileJob.SetContent("package main\n" +
21+
"func main() {\n" +
22+
"\tc := '\"'\n" +
23+
"\t/* block\n" +
24+
"\t comment */\n" +
25+
"}")
26+
27+
CountStats(&fileJob)
28+
29+
if fileJob.Code != 4 {
30+
t.Errorf("Expected 4 code got %d", fileJob.Code)
31+
}
32+
if fileJob.Comment != 2 {
33+
t.Errorf("Expected 2 comments got %d", fileJob.Comment)
34+
}
35+
}
36+
37+
func TestCountStatsCharLiteralJava(t *testing.T) {
38+
ProcessConstants()
39+
fileJob := FileJob{Language: "Java"}
40+
fileJob.SetContent("class T {\n" +
41+
" void m() {\n" +
42+
" char c = '\"';\n" +
43+
" /* block\n" +
44+
" comment */\n" +
45+
" }\n" +
46+
"}")
47+
48+
CountStats(&fileJob)
49+
50+
if fileJob.Code != 5 {
51+
t.Errorf("Expected 5 code got %d", fileJob.Code)
52+
}
53+
if fileJob.Comment != 2 {
54+
t.Errorf("Expected 2 comments got %d", fileJob.Comment)
55+
}
56+
}
57+
58+
func TestCountStatsCharLiteralCSharp(t *testing.T) {
59+
ProcessConstants()
60+
fileJob := FileJob{Language: "C#"}
61+
fileJob.SetContent("class T {\n" +
62+
" void M() {\n" +
63+
" char c = '\"';\n" +
64+
" /* block\n" +
65+
" comment */\n" +
66+
" }\n" +
67+
"}")
68+
69+
CountStats(&fileJob)
70+
71+
if fileJob.Code != 5 {
72+
t.Errorf("Expected 5 code got %d", fileJob.Code)
73+
}
74+
if fileJob.Comment != 2 {
75+
t.Errorf("Expected 2 comments got %d", fileJob.Comment)
76+
}
77+
}

0 commit comments

Comments
 (0)