Skip to content

Commit

Permalink
add uloc html output
Browse files Browse the repository at this point in the history
  • Loading branch information
boyter committed May 1, 2024
1 parent d76baff commit 6147a04
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
15 changes: 10 additions & 5 deletions processor/formatters.go
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ func toOpenMetricsFiles(input chan *FileJob) string {
// with the express idea of lowering memory usage, see https://github.com/boyter/scc/issues/210 for
// the background on why this might be needed
func toCSVStream(input chan *FileJob) string {
fmt.Println("Language,Provider,Filename,Lines,Code,Comments,Blanks,Complexity,Bytes")
fmt.Println("Language,Provider,Filename,Lines,Code,Comments,Blanks,Complexity,Bytes,Uloc")

var quoteRegex = regexp.MustCompile("\"")

Expand All @@ -486,7 +486,7 @@ func toCSVStream(input chan *FileJob) string {
var location = "\"" + quoteRegex.ReplaceAllString(result.Location, "\"\"") + "\""
var filename = "\"" + quoteRegex.ReplaceAllString(result.Filename, "\"\"") + "\""

fmt.Println(fmt.Sprintf("%s,%s,%s,%s,%s,%s,%s,%s,%s",
fmt.Println(fmt.Sprintf("%s,%s,%s,%s,%s,%s,%s,%s,%s,%s",
result.Language,
location,
filename,
Expand All @@ -496,6 +496,7 @@ func toCSVStream(input chan *FileJob) string {
fmt.Sprint(result.Blank),
fmt.Sprint(result.Complexity),
fmt.Sprint(result.Bytes),
fmt.Sprint(result.Uloc),
))
}

Expand Down Expand Up @@ -575,6 +576,7 @@ func toHtmlTable(input chan *FileJob) string {
<th>Code</th>
<th>Complexity</th>
<th>Bytes</th>
<th>Uloc</th>
</tr></thead>
<tbody>`)

Expand All @@ -588,7 +590,8 @@ func toHtmlTable(input chan *FileJob) string {
<th>%d</th>
<th>%d</th>
<th>%d</th>
</tr>`, r.Name, len(r.Files), r.Lines, r.Blank, r.Comment, r.Code, r.Complexity, r.Bytes))
<th>%d</th>
</tr>`, r.Name, len(r.Files), r.Lines, r.Blank, r.Comment, r.Code, r.Complexity, r.Bytes, len(ulocLanguageCount[r.Name])))

if Files {
sortSummaryFiles(&r)
Expand All @@ -603,7 +606,8 @@ func toHtmlTable(input chan *FileJob) string {
<td>%d</td>
<td>%d</td>
<td>%d</td>
</tr>`, res.Location, res.Lines, res.Blank, res.Comment, res.Code, res.Complexity, res.Bytes))
<td>%d</td>
</tr>`, res.Location, res.Lines, res.Blank, res.Comment, res.Code, res.Complexity, res.Bytes, res.Uloc))
}
}

Expand All @@ -619,8 +623,9 @@ func toHtmlTable(input chan *FileJob) string {
<th>%d</th>
<th>%d</th>
<th>%d</th>
<th>%d</th>
</tr></tfoot>
</table>`, sumFiles, sumLines, sumBlank, sumComment, sumCode, sumComplexity, sumBytes))
</table>`, sumFiles, sumLines, sumBlank, sumComment, sumCode, sumComplexity, sumBytes, len(ulocGlobalCount)))

return str.String()
}
Expand Down
2 changes: 1 addition & 1 deletion processor/structs.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ type FileJob struct {
Complexity int64
WeightedComplexity float64
Hash hash.Hash
Callback FileJobCallback
Callback FileJobCallback `json:"-"`
Binary bool
Minified bool
Generated bool
Expand Down

0 comments on commit 6147a04

Please sign in to comment.