Duplicate symmetric write
the same fact written for (u, v) and then (v, u)
domain V = 1..=3
var adj: [V]List<V> = []
let (u, v) = (V(1), V(2))
adj[u].push(v)
adj[v].push(u)
print(adj[u].len)domain V = 1..=3
var adj: [V]List<V> = []
let (u, v) = (V(1), V(2))
for (a, b) in [(u, v), (v, u)]:
adj[a].push(b)
print(adj[u].len)Why
Writing the same value to both (u, v) and (v, u) duplicates one fact. Use Graph.undirected(...), Sym<V>, or a two-element loop so the fact lives in one place.
The practice it serves
A hand-written pattern the language or the standard library already says in one step. Family: D. Domains, positions and cuts.
Not flagged
A near miss: close to the pattern, but not it.
domain V = 1..=3
var adj: [V]List<V> = []
let (u, v) = (V(1), V(2))
adj[u].push(v)
print(adj[u].len)Turn it off
For one block, wrap it in with lint(symmetric_write: allow):. For a project, add symmetric_write = "allow" under [lints] in cp.toml.
Generated from spec/lints/symmetric_write, the same record the linter is built from.