Finding ids and the same answer every time

Every finding has a short id, such as WQ9WMD91C, that people and agents can pass to tx0 explain, tx0 fix --finding and tx0 suppress. The same inputs give the same findings and the same ids on every machine.

The same id after a rename and an edit

Each finding gets a short id computed from its rule, the enclosing function or class and the flagged code. It stays the same on every machine, when the file is renamed, and when code around it moves or is reformatted.

beforeafter git mv and a comment aboveid
api/order.go:14:2 api/orders.go:16:2 WQ9WMD91C
api/order.go:19:11 api/orders.go:21:11 7778HC4RC
jobs/retry.py:6:10 jobs/retry.py:6:10 74RVF0NHX

Commands take the id: tx0 explain ID, tx0 fix --finding ID and tx0 suppress ID --reason "...".

People and agents copy ids. The last symbol is a check symbol, so a mistyped or swapped id is rejected before tx0 acts on the wrong finding.

Eight symbols and a check symbol. Case and hyphens do not matter.

$ tx0 explain WQ9WMD91C
finding WQ9WMD91C in api/order.go
  WQ9WMD91C 14:2 warning tx0/go:self-assignment `total` is assigned to itself
    14 | 	total = total
       | 	^^^^^
    note: an assignment of a value to itself has no effect

How an id is written

Ids use Crockford's base32 digits and letters, without I, L, O and U. Case and hyphens are ignored, and I, L and O are read as 1, 1 and 0. The last symbol is a check symbol, so an id with one wrong or two swapped symbols is rejected rather than taken for another finding.

A prefix of 4 to 8 symbols works too, as long as it names one finding. The same code with the same problem in several files gets one longer id per file, which starts like the shared one.

The same answer every time

The same inputs give byte-identical output with any number of threads and in any order of edits. An incremental result always equals a run from scratch; the test suite checks this on random histories of edits.

That is what lets a hook, an editor and CI agree on a finding and its id.