diff --git a/processor/formatters.go b/processor/formatters.go index 28129363f..28d683664 100644 --- a/processor/formatters.go +++ b/processor/formatters.go @@ -31,13 +31,14 @@ var tabularShortFormatFile = "%s %9d %8d %9d %8d %10d\n" var shortFormatFileTruncate = 29 var shortNameTruncate = 20 +var tabularShortUlocLanguageFormatBody = "%40d Unique Lines of Code (ULOC)\n" +var tabularShortUlocGlobalFormatBody = "Unique Lines of Code (ULOC) %12d\n" + var tabularShortFormatHeadNoComplexity = "%-22s %11s %11s %10s %11s %9s\n" var tabularShortFormatBodyNoComplexity = "%-22s %11d %11d %10d %11d %9d\n" var tabularShortFormatFileNoComplexity = "%s %11d %10d %11d %9d\n" var longNameTruncate = 22 -var tabularUlocFormatBody = "Total Unique Source Lines of Code (ULOC) %38d\n" - var tabularWideBreak = "─────────────────────────────────────────────────────────────────────────────────────────────────────────────\n" var tabularWideBreakCi = "-------------------------------------------------------------------------------------------------------------\n" var tabularWideFormatHead = "%-33s %9s %9s %8s %9s %8s %10s %16s\n" @@ -1037,6 +1038,13 @@ func fileSummarizeShort(input chan *FileJob) string { str.WriteString(fmt.Sprintf(tabularShortFormatBodyNoComplexity, trimmedName, summary.Count, summary.Lines, summary.Blank, summary.Comment, summary.Code)) } + if UlocMode { + str.WriteString(fmt.Sprintf(tabularShortUlocLanguageFormatBody, len(ulocLanguageCount[summary.Name]))) + if summary.Name != language[len(language)-1].Name { + str.WriteString(tabularShortBreakCi) + } + } + if Files { sortSummaryFiles(&summary) str.WriteString(getTabularShortBreak()) @@ -1068,7 +1076,7 @@ func fileSummarizeShort(input chan *FileJob) string { str.WriteString(getTabularShortBreak()) if UlocMode { - str.WriteString(fmt.Sprintf(tabularUlocFormatBody, len(ulocGlobalCount))) + str.WriteString(fmt.Sprintf(tabularShortUlocGlobalFormatBody, len(ulocGlobalCount))) str.WriteString(getTabularShortBreak()) } diff --git a/processor/structs.go b/processor/structs.go index ae9266bb6..48ff27f7c 100644 --- a/processor/structs.go +++ b/processor/structs.go @@ -83,6 +83,7 @@ type FileJob struct { Minified bool Generated bool EndPoint int + Uloc int } // LanguageSummary is used to hold summarised results for a single language diff --git a/processor/workers.go b/processor/workers.go index ee220e491..e0b1da8b3 100644 --- a/processor/workers.go +++ b/processor/workers.go @@ -570,6 +570,14 @@ func CountStats(fileJob *FileJob) { fileJob.Hash.Sum(nil) } + if UlocMode && Files { + uloc := map[string]struct{}{} + for _, l := range strings.Split(string(fileJob.Content), "\n") { + uloc[l] = struct{}{} + } + fileJob.Uloc = len(uloc) + } + isGenerated := false if Generated {