Skip to content

Commit

Permalink
play around with uloc display
Browse files Browse the repository at this point in the history
  • Loading branch information
boyter committed May 1, 2024
1 parent 594e3a7 commit 0a843fe
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
14 changes: 11 additions & 3 deletions processor/formatters.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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())
Expand Down Expand Up @@ -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())
}

Expand Down
1 change: 1 addition & 0 deletions processor/structs.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions processor/workers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 0a843fe

Please sign in to comment.