← All lints

domain_spelling

L0512Idiomswarn

Non-canonical domain/sequence method spelling

D.sorted(by:) -> D.sort(by:); xs.first(where: p) -> xs.first(p)

Flagged
domain V = 1..=3
let a: [V]Int = [3, 1, 2]
let _ = V.sorted(by: a)
let _ = V.first(where: v => a[v] > 1)
Write instead
domain V = 1..=3
let a: [V]Int = [3, 1, 2]
let _ = V.sort(by: a)
let _ = V.find(v => a[v] > 1)

Why

Domains follow the one-spelling sequence rules: sort a domain with D.sort(by: key) (matching xs.sort(by: key)), and search with .find(p), the predicate positional (not .first(where: p), decisions.md §182). cpl fix rewrites both.

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.

Near miss
domain V = 1..=3
let a: [V]Int = [3, 1, 2]
print(a.sum())

Turn it off

For one block, wrap it in with lint(domain_spelling: allow):. For a project, add domain_spelling = "allow" under [lints] in cp.toml.

Generated from spec/lints/domain_spelling, the same record the linter is built from.