Skip to content

sift 1.30.0 — Racket, and what a definition costs

Choose a tag to compare

@jjba23 jjba23 released this 14 Nov 09:43
· 25 commits to trunk since this release
aeb96eb

Racket is the fourth dialect, and the first release that indexes a standard
library sift did not ship a program for.

Racket is read by its own report. A .rkt, .rktd, .rktl or .scrbl
file, a shebang naming racket, or a #lang line is a Racket module; the
#lang line is a node of its own, so the formatter keeps it whole and puts the
blank line after it that a Racket module has. #:height is a keyword rather
than an uninterned symbol, and #hash, #rx"...", #s(posn ...) and #&box
keep the datum glued to the reader prefix that produced it. A square bracket is
a cond or match clause, and #{...}# — which only Guile reads — is reported
as the syntax it is not. The rules whose premise is another dialect's
(unused-import, call-arity, case-literal-datum, negated-if,
docstring-texinfo) do not run on a Racket file, because a finding a reader has
to argue with is worse than no finding at all. Formatting, linting, the
language server, the editor integrations and the browser build all take
racket as a dialect.

A Racket standard library, read from source. sift lsp no longer answers
"no file defines this" for every name in racket/base. Racket ships collects
and pkgs as source, so the index is read the way Guile's is: the installation
the racket on the path belongs to, the version trees a --user package went
into, and whatever PLTCOLLECTS names. No Racket program is shipped to
describe it. The name that only the compiled #%kernel defines is the one it
cannot answer, and it answers that as a file that does not exist rather than as
a guess. struct is a defining form, so the outline, rename and inlay hints
see one.

Two rules about what a definition costs. SIFT094 cognitive-complexity
charges one for a branch and one more for each branch inside it;
SIFT095 cyclomatic-complexity counts the paths a test would have to cover.
Both are info, and both budgets are settings — max-cognitive-complexity (15)
and max-cyclomatic-complexity (10) — because a program that spawns processes
for a living may nest more than one that formats a buffer. They read the
measurement maak complexity prints, from (sift complexity), so a finding and
the report cannot disagree about the same function. Moving that measurement
fixed one thing it had already claimed: a quoted datum is data, so
'(if a (cond [b 1])) is no longer three branches. A cond stays one decision
rather than one per clause, which is what the report has always counted.

The catalogue is 95 rules. Nothing that worked before stops working: the two
rules are info, so a project at severity: warning neither shows them nor
fails on them, and a project that wants them says so with a budget.

Full Changelog: v1.29.2...v1.30.0