unique_by
No two files matching select may share the value of key (a path template; tokens {path}/{dir}/{basename}/{stem}/{ext}/{parent_name}). Catches basename collisions across subdirectories. With case_insensitive: true the key is folded to lowercase before grouping, so README.md and readme.md collide — the case-insensitive-filesystem hazard (Windows / macOS).
Options
Section titled “Options”| Option | Type | Required | Default | Description |
|---|---|---|---|---|
case_insensitive | boolean | false | Fold the key to lowercase before grouping, so keys that collide only under case-folding count as duplicates - the case-insensitive-filesystem hazard (Windows / macOS). | |
key | string | {basename} | Path-template producing a key per matched file. Default: {basename}. | |
select | string | yes | Glob selecting the files to deduplicate. |
Plus the common level, id, and when fields. This rule analyses the whole repository, so it takes no paths. This table is generated from the JSON Schema; option types and defaults are authoritative.
Example
Section titled “Example”Two files colliding on the same stem
Section titled “Two files colliding on the same stem”The rule fires on this repository:
a/a/util.rsb/b/util.rsc/c/other.rspub fn a() {}pub fn b() {}pub fn c() {}With this .alint.yml:
version: 1rules: - id: unique-rs-stems kind: unique_by select: "**/*.rs" key: "{stem}" level: warningalint check reports:
--- a/util.rs ------------------------------------------------------------------ ! warning unique-rs-stems duplicate key "util" shared by 2 file(s): a/util.rs, b/util.rs
Summary (1 violation): ! 1 warning 0 passing * 1 failingEvery file has a distinct stem
Section titled “Every file has a distinct stem”This repository is compliant:
src/src/alpha.rssrc/beta.rssrc/gamma.rsWith this .alint.yml:
version: 1rules: - id: unique-rs-stems kind: unique_by select: "**/*.rs" key: "{stem}" level: warningalint check reports:
v All 1 rule(s) passed.