- commit
- 6fef7ff87932957efb9097a34cc96f84227b5674
- parent
- 3facf5ea6f57e7e2435792869e2ff4e01d17bdb6
- author
- Dami <dami.etoile@gmail.com>
| M | Makefile | 7 | ++++++- |
| M | docs/ | 1 | + |
| A | scripts/ | 29 | +++++++++++++++++++++++++++++ |
@@ -7,7 +7,7 @@ GHOSTTY_SRC := $(DEPS)/ghostty-src
77 GHOSTTY_OUT := $(DEPS)/ghostty88 GHOSTTY_STAMP := $(GHOSTTY_OUT)/.built-$(GHOSTTY_COMMIT)99 10-10+1111 1212 build:1313 CGO_ENABLED=0 go build -o bin/012 ./cmd/012@@ -18,6 +18,11 @@ run: build
1818 test:1919 go test ./...2020 21+# Code shape limits: cognitive complexity and file length.22+lint:23+ go vet ./...24+ scripts/lint.sh25+2126 fuzz:2227 go test ./internal/sheet -run '^$$' -fuzz FuzzParse -fuzztime 60s2328 go test ./internal/fileio -run '^$$' -fuzz FuzzReadDelimited -fuzztime 60s@@ -1,6 +1,7 @@
11 # Testing22 33 ```sh4+make lint # go vet, cognitive complexity at most 25, Go files at most 500 lines45 make test # engine, file formats and UI unit tests56 make fuzz # fuzz the formula parser and the CSV and .wk1 readers67 make oracle # compare formulas and number formats with excelize@@ -0,0 +1,29 @@
1+2+# Code shape limits, checked by make lint:3+# - no function with cognitive complexity over 25 (gocognit)4+# - no Go file over 500 lines5+# gocognit runs with go run at a pinned version, so it never enters go.mod.6+set -eu7+cd "$(dirname "$0")/.."8+9+GOCOGNIT=github.com/uudashr/gocognit/cmd/gocognit@v1.2.110+MAX_COGNIT=2511+MAX_LINES=50012+fail=013+14+dirs=$(find cmd internal demos e2e oracle -name '*.go' -exec dirname {} \; | sort -u)15+over=$(go run $GOCOGNIT -over $MAX_COGNIT $dirs || true)16+if [ -n "$over" ]; then17+ echo "cognitive complexity over $MAX_COGNIT:"18+ echo "$over" | sort -rn19+ fail=120+fi21+22+long=$(find cmd internal demos e2e oracle -name '*.go' -exec wc -l {} + | awk -v max=$MAX_LINES '$2 != "total" && $1 > max')23+if [ -n "$long" ]; then24+ echo "files over $MAX_LINES lines:"25+ echo "$long" | sort -rn26+ fail=127+fi28+29+exit $fail