From 21b48c8c4195c5af2622e1fb4ded3766759d8b54 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Mon, 28 Sep 2026 21:29:54 +0200 Subject: [PATCH] Correct the false comments and delete dead code --- cmd/fejkdata/main.go | 2 +- fejkdata.go | 6 +++--- format.go | 2 +- node.go | 2 +- struct.go | 2 +- table.go | 10 ---------- todo.md | 6 ------ 7 files changed, 7 insertions(+), 23 deletions(-) diff --git a/cmd/fejkdata/main.go b/cmd/fejkdata/main.go index 4d39720..04f8d86 100644 --- a/cmd/fejkdata/main.go +++ b/cmd/fejkdata/main.go @@ -224,7 +224,7 @@ type recordFormat struct { } // recordFormats is every --format that writes records. json frames the records -// as one array document; ndjson is the same column, one object per line. +// as one array document; ndjson writes one object per line. var recordFormats = map[string]recordFormat{ "csv": {header: (*fejkdata.Record).CSVHeader, line: func(r *fejkdata.Record, _ string) string { return r.CSVLine() }, sep: "\n"}, "json": {line: jsonLine, open: "[", close: "]", sep: ",\n"}, diff --git a/fejkdata.go b/fejkdata.go index def390f..f18fa4f 100644 --- a/fejkdata.go +++ b/fejkdata.go @@ -28,8 +28,8 @@ var ErrNoData = errors.New("no data: WithoutShippedData needs at least one WithD // Generator generates fake data from a loaded namespace tree. Create one with [New]. // It is safe for concurrent use; a seeded sequence is reproducible only when drawn -// from one goroutine. The compiled tree is immutable after [New], so List reads it -// without a lock; mu guards the rest, which every other entry point takes. +// from one goroutine. The compiled tree is immutable after [New], so List, NewTemplate +// and NewRecordTemplate read it without a lock; mu guards the rest, which every render takes. type Generator struct { mu sync.Mutex rand *session @@ -120,7 +120,7 @@ func New(opts ...Option) (*Generator, error) { // List returns the sorted dotted paths Fake can render: every category, the dotted // fields within a template, and folder segments. A choice consumes no segment, so a // path continues through one only where every variant carries it, which is the -// rule Fake applies too: List is the set of paths Fake accepts. +// rule Fake applies too. A selector is left out: Fake also takes `[key]` after a table. func (f *Generator) List() []string { var out []string for _, name := range sortedNames(f.categories) { diff --git a/format.go b/format.go index 16ef085..941bc17 100644 --- a/format.go +++ b/format.go @@ -133,7 +133,7 @@ type builtin struct { // funcCall splits a "{token}" body shaped name(args) into its parts; ok is false // for a plain field or alternation body. A '(' without a trailing ')' yields -// ok=false; checkFunc reports it as malformed at compile time. +// ok=false; parseFormat reports it as malformed. func funcCall(body string) (name string, args []string, ok bool) { lp := indexOutside(body, '(') if lp < 0 || !strings.HasSuffix(body, ")") { diff --git a/node.go b/node.go index 6ff24de..f4a689c 100644 --- a/node.go +++ b/node.go @@ -298,7 +298,7 @@ func checkNoRepeatedItem(items []any) error { } return fmt.Errorf("choice item %d repeats item %d; skew the odds with a weight on one of them instead", i, j) } - seen[string(key)] = i + seen[key] = i } return nil } diff --git a/struct.go b/struct.go index da98175..67f5643 100644 --- a/struct.go +++ b/struct.go @@ -123,7 +123,7 @@ func (sc *structCompile) spend(label string) error { return fmt.Errorf(`%s: the struct fields reach more than %d structs; leave a struct field unfilled with fake:"-"`, label, maxStructs) } -// t sits at index within c.t. +// t sits at index within c.typ. func (c *structFields) gatherFields(t reflect.Type, index []int) error { for i := 0; i < t.NumField(); i++ { sf := t.Field(i) diff --git a/table.go b/table.go index 7ba2b2b..65b2ec8 100644 --- a/table.go +++ b/table.go @@ -538,16 +538,6 @@ func (t *table) descendant(name string) *table { // parentRow is the row of t's parent that row r links to. func (t *table) parentRow(r int) int { return t.parentT.byKey[t.cell(r, t.parentIndex)] } -// descends reports whether a is an ancestor of t. -func (t *table) descends(a *table) bool { - for p := t.parentT; p != nil; p = p.parentT { - if p == a { - return true - } - } - return false -} - // under reports whether row r of t sits inside row pr of ancestor a. func (t *table) under(r int, a *table, pr int) bool { for c, row := t, r; c.parentT != nil; c, row = c.parentT, c.parentRow(row) { diff --git a/todo.md b/todo.md index b23ebbd..711f715 100644 --- a/todo.md +++ b/todo.md @@ -21,12 +21,6 @@ Self-sufficiency 5.6), every seat capped by Locality, and all nine naming This round, in order: -- Correct the false comments: `funcCall` names `checkFunc` where `parseFormat` - reports, `struct.go`'s "t sits at index within c.t" names no field, `recordFormats` - calls ndjson "the same column", `Generator` says every other entry point takes `mu` - where `NewTemplate` and `NewRecordTemplate` do not, and `List` claims to be every - path `Fake` accepts, which a selector is too. Delete the dead `table.descends` and - the redundant `string(key)` in `checkNoRepeatedItem`. - Delete the decision "The rows of a table are alternatives": it defines `alternatives`, which its comment in `drawfence.go` already does. Point the README's "which pairs are weighed against each other" at that comment's rule, stated in the README's Table