Skip to content

Commit 6c45375

Browse files
committed
add in dryness calculation
1 parent e349fb1 commit 6c45375

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

main.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,13 @@ func main() {
5959
false,
6060
"calculate the number of unique lines of code (ULOC) for the project",
6161
)
62+
flags.BoolVarP(
63+
&processor.Dryness,
64+
"dryness",
65+
"a",
66+
false,
67+
"calculate the dryness/wetness of the project (implies --uloc)",
68+
)
6269
flags.BoolVar(
6370
&processor.DisableCheckBinary,
6471
"binary",

processor/formatters.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1077,6 +1077,10 @@ func fileSummarizeShort(input chan *FileJob) string {
10771077

10781078
if UlocMode {
10791079
str.WriteString(fmt.Sprintf(tabularShortUlocGlobalFormatBody, len(ulocGlobalCount)))
1080+
if Dryness {
1081+
dryness := float64(len(ulocGlobalCount)) / float64(sumLines)
1082+
str.WriteString(fmt.Sprintf("DRYness %% %30.2f\n", dryness))
1083+
}
10801084
str.WriteString(getTabularShortBreak())
10811085
}
10821086

processor/processor.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,9 @@ var DisableCheckBinary = false
105105
// UlocMode toggles checking for binary files using NUL bytes
106106
var UlocMode = false
107107

108+
// Dryness toggles checking for binary files using NUL bytes
109+
var Dryness = false
110+
108111
// SortBy sets which column output in formatter should be sorted by
109112
var SortBy = ""
110113

@@ -467,6 +470,10 @@ func processFlags() {
467470
Generated = true
468471
}
469472

473+
if Dryness {
474+
UlocMode = true
475+
}
476+
470477
if Debug {
471478
printDebug(fmt.Sprintf("Path Deny List: %v", PathDenyList))
472479
printDebug(fmt.Sprintf("Sort By: %s", SortBy))
@@ -481,6 +488,8 @@ func processFlags() {
481488
printDebug(fmt.Sprintf("Minified/Generated Detection: %t/%t", Minified, Generated))
482489
printDebug(fmt.Sprintf("Ignore Minified/Generated: %t/%t", IgnoreMinified, IgnoreGenerated))
483490
printDebug(fmt.Sprintf("IncludeSymLinks: %t", IncludeSymLinks))
491+
printDebug(fmt.Sprintf("Uloc: %t", UlocMode))
492+
printDebug(fmt.Sprintf("Dryness: %t", Dryness))
484493
}
485494
}
486495

0 commit comments

Comments
 (0)