From bc065ad917525016379ab093cd34ba7205ade022 Mon Sep 17 00:00:00 2001 From: Ben Boyter Date: Wed, 5 Jan 2022 08:38:34 +1100 Subject: [PATCH] slight fix for https://github.com/boyter/scc/issues/311 --- SCC-OUTPUT-REPORT.html | 22 +++++++++++----------- processor/formatters.go | 28 ++++++++++++++++------------ 2 files changed, 27 insertions(+), 23 deletions(-) diff --git a/SCC-OUTPUT-REPORT.html b/SCC-OUTPUT-REPORT.html index f47a19d3..60473d71 100644 --- a/SCC-OUTPUT-REPORT.html +++ b/SCC-OUTPUT-REPORT.html @@ -12,12 +12,12 @@ Go 36 - 9090 - 1443 + 9094 + 1445 429 - 7218 + 7220 1481 - 357991 + 358069 Java 24 @@ -39,12 +39,12 @@ Markdown 11 - 1347 + 1348 319 0 - 1028 + 1029 0 - 54838 + 54998 Python 10 @@ -607,11 +607,11 @@ Total 176 - 26940 - 3041 + 26945 + 3043 1765 - 22134 + 22137 2467 - 1815589 + 1815827 \ No newline at end of file diff --git a/processor/formatters.go b/processor/formatters.go index 33adf868..2e60ab70 100644 --- a/processor/formatters.go +++ b/processor/formatters.go @@ -333,17 +333,7 @@ func toCSVSummary(input chan *FileJob) string { } func toCSVFiles(input chan *FileJob) string { - records := [][]string{{ - "Language", - "Location", - "Filename", - "Lines", - "Code", - "Comments", - "Blanks", - "Complexity", - "Bytes"}, - } + records := [][]string{} for result := range input { records = append(records, []string{ @@ -411,9 +401,23 @@ func toCSVFiles(input chan *FileJob) string { }) } + recordsEnd := [][]string{{ + "Language", + "Location", + "Filename", + "Lines", + "Code", + "Comments", + "Blanks", + "Complexity", + "Bytes"}, + } + + recordsEnd = append(recordsEnd, records...) + b := &bytes.Buffer{} w := csv.NewWriter(b) - _ = w.WriteAll(records) + _ = w.WriteAll(recordsEnd) w.Flush() return b.String()