Correct the false comments and delete dead code

This commit is contained in:
2026-09-28 21:29:54 +02:00
committed by Lillem4n
parent a84997d2f4
commit 21b48c8c41
7 changed files with 7 additions and 23 deletions
+1 -1
View File
@@ -224,7 +224,7 @@ type recordFormat struct {
} }
// recordFormats is every --format that writes records. json frames the records // 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{ var recordFormats = map[string]recordFormat{
"csv": {header: (*fejkdata.Record).CSVHeader, line: func(r *fejkdata.Record, _ string) string { return r.CSVLine() }, sep: "\n"}, "csv": {header: (*fejkdata.Record).CSVHeader, line: func(r *fejkdata.Record, _ string) string { return r.CSVLine() }, sep: "\n"},
"json": {line: jsonLine, open: "[", close: "]", sep: ",\n"}, "json": {line: jsonLine, open: "[", close: "]", sep: ",\n"},
+3 -3
View File
@@ -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]. // 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 // 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 // from one goroutine. The compiled tree is immutable after [New], so List, NewTemplate
// without a lock; mu guards the rest, which every other entry point takes. // and NewRecordTemplate read it without a lock; mu guards the rest, which every render takes.
type Generator struct { type Generator struct {
mu sync.Mutex mu sync.Mutex
rand *session 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 // 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 // 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 // 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 { func (f *Generator) List() []string {
var out []string var out []string
for _, name := range sortedNames(f.categories) { for _, name := range sortedNames(f.categories) {
+1 -1
View File
@@ -133,7 +133,7 @@ type builtin struct {
// funcCall splits a "{token}" body shaped name(args) into its parts; ok is false // 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 // 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) { func funcCall(body string) (name string, args []string, ok bool) {
lp := indexOutside(body, '(') lp := indexOutside(body, '(')
if lp < 0 || !strings.HasSuffix(body, ")") { if lp < 0 || !strings.HasSuffix(body, ")") {
+1 -1
View File
@@ -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) 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 return nil
} }
+1 -1
View File
@@ -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) 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 { func (c *structFields) gatherFields(t reflect.Type, index []int) error {
for i := 0; i < t.NumField(); i++ { for i := 0; i < t.NumField(); i++ {
sf := t.Field(i) sf := t.Field(i)
-10
View File
@@ -538,16 +538,6 @@ func (t *table) descendant(name string) *table {
// parentRow is the row of t's parent that row r links to. // 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)] } 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. // 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 { 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) { for c, row := t, r; c.parentT != nil; c, row = c.parentT, c.parentRow(row) {
-6
View File
@@ -21,12 +21,6 @@ Self-sufficiency 5.6), every seat capped by Locality, and all nine naming
This round, in order: 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`, - 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 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 weighed against each other" at that comment's rule, stated in the README's Table