Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ Flags:
-u, --uloc calculate the number of unique lines of code (ULOC) for the project
-v, --verbose verbose output
--version version for scc
-w, --wide wider output with additional statistics (implies --complexity)
-w, --wide wider output with additional statistics (overrides --no-complexity)
```

Output should look something like the below for the redis project
Expand Down
4 changes: 2 additions & 2 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ func registerFlags(flags *pflag.FlagSet, b *flagBindings) {
// ReportOut to processor.DefaultReportName to tell "bare flag" apart from an
// explicit path, so the two must stay in sync.
flags.Lookup("report").NoOptDefVal = processor.DefaultReportName
flags.StringVar(strVar(&processor.ReportSkip), "report-skip", "", "comma-separated sections to omit (cocomo,locomo,hotspots,coupling,authors,timeline,files,uloc,linelength,card)")
flags.StringVar(strVar(&processor.ReportSkip), "report-skip", "", "comma-separated sections to omit ("+strings.Join(processor.ReportSkipSections, ",")+")")
flags.StringVar(strVar(&processor.ReportTitle), "report-title", "", "override the repo name shown in the report banner")
flags.StringSliceVarP(sliceVar(&processor.AllowListExtensions), "include-ext", "i", []string{}, "limit to file extensions [comma separated list: e.g. go,java,js]")
flags.StringSliceVarP(sliceVar(&processor.ExcludeListExtensions), "exclude-ext", "x", []string{}, "ignore file extensions (overrides include-ext) [comma separated list: e.g. go,java,js]")
Expand Down Expand Up @@ -433,7 +433,7 @@ func registerFlags(flags *pflag.FlagSet, b *flagBindings) {
flags.StringVarP(strVar(&processor.SortBy), "sort", "s", "files", "column to sort by [files, name, lines, blanks, code, comments, complexity]")
flags.BoolVarP(boolVar(&processor.Trace), "trace", "t", false, "enable trace output (not recommended when processing multiple files)")
flags.BoolVarP(boolVar(&processor.Verbose), "verbose", "v", false, "verbose output")
flags.BoolVarP(boolVar(&processor.More), "wide", "w", false, "wider output with additional statistics (implies --complexity)")
flags.BoolVarP(boolVar(&processor.More), "wide", "w", false, "wider output with additional statistics (overrides --no-complexity)")
flags.BoolVar(boolVar(&processor.NoLarge), "no-large", false, "ignore files over certain byte and line size set by large-line-count and large-byte-count")
flags.BoolVar(boolVar(&processor.IncludeSymLinks), "include-symlinks", false, "if set will count symlink files")
flags.Int64Var(int64Var(&processor.LargeLineCount), "large-line-count", 40000, "number of lines a file can contain before being removed from output")
Expand Down
15 changes: 2 additions & 13 deletions processor/report.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,22 +42,11 @@ var ReportSkipNames = map[string]bool{}
// (spec 05). Empty means "auto-detect".
var ReportTitle = ""

// reportSkipRecognised is the set of section names --report-skip accepts.
// ReportSkipSections is the list of section names --report-skip accepts.
// Kept here (next to ReportSkipped) so future template authors can find the
// authoritative list in one place. Names must match what the report template
// and CollectReportData branch on. Spec 05 fixes this set.
var reportSkipRecognised = map[string]bool{
"cocomo": true,
"locomo": true,
"hotspots": true,
"coupling": true,
"authors": true,
"timeline": true,
"files": true,
"uloc": true,
"linelength": true,
"card": true,
}
var ReportSkipSections = []string{"cocomo", "locomo", "hotspots", "coupling", "authors", "timeline", "files", "uloc", "linelength", "card"}

// ReportSkipped reports whether the given section name was listed in
// --report-skip. Section names are case-insensitive — callers can pass
Expand Down
5 changes: 3 additions & 2 deletions processor/report_render.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"math"
"net/url"
"os"
"slices"
"sort"
"strings"
"sync"
Expand Down Expand Up @@ -65,8 +66,8 @@ func parseReportSkipTo(raw string, warnW io.Writer) {
if name == "" {
continue
}
if !reportSkipRecognised[name] {
_, _ = fmt.Fprintf(warnW, "warning: --report-skip: unknown section %q (recognised: cocomo, locomo, hotspots, coupling, authors, timeline, files, uloc, linelength, card)\n", name)
if !slices.Contains(ReportSkipSections, name) {
_, _ = fmt.Fprintf(warnW, "warning: --report-skip: unknown section %q (recognised: %s)\n", name, strings.Join(ReportSkipSections, ", "))
}
ReportSkipNames[name] = true
}
Expand Down
14 changes: 5 additions & 9 deletions processor/report_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"math"
"os"
"path/filepath"
"slices"
"strings"
"testing"
"time"
Expand Down Expand Up @@ -329,9 +330,9 @@ func TestParseReportSkipKnownNames(t *testing.T) {
withReportSkipReset(t)

var warn bytes.Buffer
parseReportSkipTo("Cocomo, Locomo, hotspots, AUTHORS, timeline, files, uloc, linelength, card", &warn)
parseReportSkipTo(strings.ToUpper(strings.Join(ReportSkipSections, ", ")), &warn)

for _, name := range []string{"cocomo", "locomo", "hotspots", "authors", "timeline", "files", "uloc", "linelength", "card"} {
for _, name := range ReportSkipSections {
if !ReportSkipped(name) {
t.Errorf("ReportSkipped(%q) = false, want true after parseReportSkip", name)
}
Expand Down Expand Up @@ -528,13 +529,8 @@ func TestReportImplicitlyEnablesULOCAndLineLength(t *testing.T) {
// add or drop one without updating the spec.
func TestReportSkipRecognisedListMatchesSpec(t *testing.T) {
want := []string{"cocomo", "locomo", "hotspots", "coupling", "authors", "timeline", "files", "uloc", "linelength", "card"}
if len(reportSkipRecognised) != len(want) {
t.Errorf("reportSkipRecognised size = %d, want %d", len(reportSkipRecognised), len(want))
}
for _, name := range want {
if !reportSkipRecognised[name] {
t.Errorf("reportSkipRecognised missing %q", name)
}
if !slices.Equal(ReportSkipSections, want) {
t.Errorf("ReportSkipSections = %v, want %v", ReportSkipSections, want)
}
}

Expand Down
Loading