Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit8efd270

Browse files
committed
feat: add map for summary
1 parent4222c63 commit8efd270

File tree

2 files changed

+26
-5
lines changed

2 files changed

+26
-5
lines changed

‎pkg/domain/cloc/cloc_summary.go‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
package cloc
22

3+
4+
5+
36
// LanguageSummary to generate output like cloc
47
typeLanguageSummaryClocstruct {
58
Namestring`yaml:"name"`
@@ -37,7 +40,4 @@ type LanguageReportEnd struct {
3740
typeClocSummarystruct {
3841
HeaderHeaderStruct
3942
SumSummaryStruct`yaml:"SUM,omitempty"`
40-
Java*LanguageSummaryCloc`yaml:"Java,omitempty"`
41-
Kotlin*LanguageSummaryCloc`yaml:"Kotlin,omitempty"`
42-
Groovy*LanguageSummaryCloc`yaml:"Groovy,omitempty"`
4343
}

‎pkg/domain/cloc/cloc_summary_test.go‎

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
11
package cloc
22

33
import (
4+
"encoding/json"
5+
"fmt"
46
."github.com/onsi/gomega"
57
"gopkg.in/yaml.v2"
68
"log"
79
"testing"
10+
"github.com/boyter/scc/processor"
811
)
912

1013
funcTest_Yaml_Parse_Model(t*testing.T) {
1114
t.Parallel()
1215
g:=NewGomegaWithT(t)
1316

14-
1517
vardata=`
1618
header:
1719
url: https://github.com/boyter/scc/
@@ -37,7 +39,6 @@ func Test_Cloc_Yaml_File_Parse_Model(t *testing.T) {
3739
t.Parallel()
3840
g:=NewGomegaWithT(t)
3941

40-
4142
vardata=`
4243
# https://github.com/boyter/scc/
4344
header:
@@ -71,3 +72,23 @@ SUM:
7172
g.Expect(header.Header.Version).To(Equal("2.13.0"))
7273
g.Expect(header.Sum.Code).To(Equal(int64(3010)))
7374
}
75+
76+
funcTest_parser_json_languages(t*testing.T) {
77+
t.Parallel()
78+
g:=NewGomegaWithT(t)
79+
80+
vardata=`[
81+
{"Name":"Java","Bytes":21169200,"CodeBytes":0,"Lines":540043,"Code":381028,"Comment":93196,"Blank":65819,"Complexity":43899,"Count":4435,"WeightedComplexity":0,"Files":[]},
82+
{"Name":"Kotlin","Bytes":6961705,"CodeBytes":0,"Lines":168900,"Code":118448,"Comment":30743,"Blank":19709,"Complexity":7636,"Count":1315,"WeightedComplexity":0,"Files":[]}
83+
]
84+
`
85+
86+
varf []processor.LanguageSummary
87+
err:=json.Unmarshal([]byte(data),&f)
88+
iferr!=nil {
89+
fmt.Println("Error parsing JSON: ",err)
90+
}
91+
fmt.Println(f)
92+
93+
g.Expect(len(f)).To(Equal(2))
94+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp