Answer prose round 2: a complexity rule whose exception excepts, and plainer walk and ancestor comments
This commit is contained in:
@@ -24,7 +24,7 @@
|
|||||||
before paraphrasing it, and name the register you read before claiming none
|
before paraphrasing it, and name the register you read before claiming none
|
||||||
publishes a spelling.
|
publishes a spelling.
|
||||||
- A README example is a `json` block that loads and renders as a category; `readme_test.go` runs every one.
|
- A README example is a `json` block that loads and renders as a category; `readme_test.go` runs every one.
|
||||||
- Cyclomatic complexity is gated at 14. Split a function that would go over it, except a table-shaped dispatch at 14, a switch with one case per kind of its input, which stays whole.
|
- Cyclomatic complexity is gated at 14: split a function that would go over it. A table-shaped dispatch, a switch with one case per kind of its input, may sit at 14 and stays whole.
|
||||||
|
|
||||||
# Decisions
|
# Decisions
|
||||||
|
|
||||||
|
|||||||
@@ -8,10 +8,10 @@ import (
|
|||||||
"github.com/larvit/fejkdata/internal/invariant"
|
"github.com/larvit/fejkdata/internal/invariant"
|
||||||
)
|
)
|
||||||
|
|
||||||
// eachNode visits n and every node inside it once, passing fn the label an error names each
|
// eachNode visits n and every node inside it once, and passes fn each node with the label an
|
||||||
// by: the dot path reaching it, then ", line N" for a table cell. It never crosses a
|
// error uses for it: the dot path reaching it, then ", line N" for a table cell. It never
|
||||||
// reference edge — a {/path} reference is skipped — so a single inline node is walked on
|
// crosses a reference edge — a {/path} reference is skipped — so a single inline node is
|
||||||
// its own.
|
// walked on its own.
|
||||||
func eachNode(n node, label string, fn func(label string, n node) error) error {
|
func eachNode(n node, label string, fn func(label string, n node) error) error {
|
||||||
seen := map[node]bool{}
|
seen := map[node]bool{}
|
||||||
var visit func(string, node) error
|
var visit func(string, node) error
|
||||||
|
|||||||
@@ -436,8 +436,8 @@ func (t *table) proveParent(siblings map[string]node) (*table, error) {
|
|||||||
return p, nil
|
return p, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// checkAncestors refuses a cycle in the chain of parents from p, t's parent, and an ancestor
|
// checkAncestors refuses a cycle in the chain of parents starting at p, t's parent, and
|
||||||
// with a column named like t.
|
// refuses an ancestor that has a column named like t.
|
||||||
func (t *table) checkAncestors(p *table, siblings map[string]node) error {
|
func (t *table) checkAncestors(p *table, siblings map[string]node) error {
|
||||||
var ancestors []*table
|
var ancestors []*table
|
||||||
for q, seen := p, map[*table]bool{t: true}; q != nil; q, _ = siblings[q.header[q.parentIndex]].(*table) {
|
for q, seen := p, map[*table]bool{t: true}; q != nil; q, _ = siblings[q.header[q.parentIndex]].(*table) {
|
||||||
|
|||||||
@@ -469,7 +469,7 @@ Its doc says render failure, and it wraps what `NewTemplate` and `NewRecordTempl
|
|||||||
|
|
||||||
### 116. Turn a row index into its rows file's line in one function.
|
### 116. Turn a row index into its rows file's line in one function.
|
||||||
|
|
||||||
Today `namedNode`'s cell line in `graph.go` and each error in `table.go` add the header line and the one-based count. Item 102 moves the rows into `internal/rows`; the function goes with them.
|
Today `namedNode`'s cell line in `graph.go` and each site in `table.go` add the header line and the one-based count. Item 102 moves the rows into `internal/rows`; the function goes with them.
|
||||||
|
|
||||||
### 56. Build on a manual run of `test.yml`.
|
### 56. Build on a manual run of `test.yml`.
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user