Five unused functions and fields removed, a deprecated constant replaced, two test mistakes fixed. ST1005 is off in staticcheck.conf: errors are shown to users as sentences.
- commit
- ec408020c239ffc8692a5001b49383fabec67ee6
- parent
- 23f0bf06ca18390900d605424164e381bd540711
- author
- Dami <dami.etoile@gmail.com>
| M | cmd/ | 16 | ---------------- |
| M | internal/ | 1 | - |
| M | internal/ | 10 | ---------- |
| M | internal/ | 3 | ++- |
| M | internal/ | 8 | -------- |
| M | internal/ | 9 | ++++----- |
| M | internal/ | 2 | +- |
| M | internal/ | 2 | +- |
| M | scripts/ | 19 | +++++++++++++++++-- |
| A | staticcheck.conf | 4 | ++++ |
@@ -2,7 +2,6 @@ package main
22 33 import (44 "log/slog"5- "os"65 "runtime/debug"76 "time"87 @@ -23,21 +22,6 @@ func telemetryConfig(c *config.Config) telemetry.Config {
2322 return tc2423 }2524 26-// telemetryFlags takes the telemetry flags (--log, --otlp) out of args,27-// and reads the rest of telemetry's settings from the config file and28-// environment. 012 serve uses it before parsing its own flags.29-func telemetryFlags(args []string) (telemetry.Config, []string, error) {30- flags, rest, err := config.ParseFlags(args)31- if err != nil {32- return telemetry.Config{}, nil, err33- }34- path, err := config.DefaultPath()35- if err != nil {36- return telemetry.Config{}, nil, err37- }38- return telemetryConfig(config.Load(path, os.Getenv, flags)), rest, nil39-}40-4125 // startTelemetry opens the log and reports every recalculation and pivot4226 // refresh to it, as spans nested in their workbook's trace.4327 func startTelemetry(c telemetry.Config) (func() error, error) {@@ -99,16 +99,6 @@ func (w *xlsxWriter) sheet(bw *bufio.Writer, ws string, snap *Snapshot, active b
9999 return r.To.Row - r.From.Row + 1100100 }101101 102-func mapKeys(m map[int]int) func(func(int) bool) {103- return func(yield func(int) bool) {104- for k := range m {105- if !yield(k) {106- return107- }108- }109- }110-}111-112102 // cell appends snapshot cell c at a as a <c> element. A formula's value113103 // is written as its cached result; a formula with no Excel equivalent,114104 // or naming a sheet that isn't written, is written as its value alone,@@ -41,8 +41,9 @@ func TestKeysAreDistinct(t *testing.T) {
4141 m[l] = l + "!"4242 }4343 c := sheet.RemoteCall{Kind: "choice", State: "x", Instructions: "q", Criteria: m}44+ want := Key(c)4445 for range 20 {45- if Key(c) != Key(c) {46+ if got := Key(c); got != want {4647 t.Fatal("map order changed the key")4748 }4849 }@@ -130,14 +130,6 @@ func (o *occupancy) colsIn(c0, c1 int) []int {
130130 return o.colIDs[i:j]131131 }132132 133-// colCells is the number of cells stored in column c.134-func (o *occupancy) colCells(c int) int {135- if ci := o.col(c); ci != nil {136- return ci.n137- }138- return 0139-}140-141133 // blockIDs returns the numbers from b0 to b1 of the blocks that any of142134 // cols has, ascending.143135 func (o *occupancy) blockIDs(cols []int, b0, b1 int) []int {@@ -83,10 +83,9 @@ func LookupFunc(name string) (*FuncDef, bool) { return functions.LookupFunc(name
8383 // Funcs returns every function, sorted by name.8484 func Funcs() []*FuncDef { return functions.Funcs() }8585 86-func num(v float64) Value { return value.Num(v) }87-func boolean(b bool) Value { return value.Boolean(b) }88-func toNum(v Value) (float64, *Value) { return value.ToNum(v) }89-func text(v Value) string { return value.AsText(v) }90-func compare(l, r Value) int { return value.Compare(l, r) }86+func num(v float64) Value { return value.Num(v) }87+func boolean(b bool) Value { return value.Boolean(b) }88+func text(v Value) string { return value.AsText(v) }89+func compare(l, r Value) int { return value.Compare(l, r) }9190 9291 func clampInt(v, lo, hi int) int { return max(lo, min(v, hi)) }@@ -210,7 +210,7 @@ func TestChartImages(t *testing.T) {
210210 t.Errorf("unchanged chart sent again")211211 }212212 press(t, m, "<f5>", "B2", "<enter>", "99", "<enter>")213- _, cmd = m.Update(nil)213+ m.Update(nil)214214 raw = nil215215 m.term.sent[firstImageID] = "stale"216216 collect(m.term.syncImages(m.sheet, m.displayCharts, &m.th, m.spans))@@ -72,7 +72,7 @@ func (t *terminal) handle(msg tea.Msg) tea.Cmd {
7272 // Ask for the cell size (for image proportions) and the7373 // palette colors charts draw with.7474 var q strings.Builder75- q.WriteString(ansi.WindowOp(ansi.RequestCellSizeWinOp))75+ q.WriteString(ansi.WindowOp(16)) // 16: report the cell size in pixels7676 for i := range 16 {7777 fmt.Fprintf(&q, "\x1b]4;%d;?\x07", i)7878 }@@ -1,16 +1,31 @@
11 2-# Code shape limits, checked by make lint:2+# Checked by make lint:3+# - staticcheck, with staticcheck.conf, in every module34 # - no function with cognitive complexity over 25 (gocognit)45 # - no Go file over 500 lines5-# gocognit runs with go run at a pinned version, so it never enters go.mod.6+# The tools run with go run at pinned versions, so they never enter go.mod.67 set -eu78 cd "$(dirname "$0")/.."89 910 GOCOGNIT=github.com/uudashr/gocognit/cmd/gocognit@v1.2.111+STATICCHECK=honnef.co/go/tools/cmd/staticcheck@2026.2.11012 MAX_COGNIT=251113 MAX_LINES=5001214 fail=01315 16+# Warnings are fixed, or turned off in staticcheck.conf with a reason;17+# none are left standing.18+for mod in . oracle e2e; do19+ if [ "$mod" = e2e ] && [ -z "${PKG_CONFIG_PATH:-}" ]; then20+ PKG_CONFIG_PATH="$(pwd)/.deps/ghostty/share/pkgconfig"21+ export PKG_CONFIG_PATH22+ fi23+ if ! (cd "$mod" && go run $STATICCHECK ./...); then24+ echo "staticcheck: findings in $mod"25+ fail=126+ fi27+done28+1429 dirs=$(find cmd internal demos e2e oracle -name '*.go' -exec dirname {} \; | sort -u)1530 over=$(go run $GOCOGNIT -over $MAX_COGNIT $dirs || true)1631 if [ -n "$over" ]; then