-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Labels
A-user-storyArea: A user story or a related issueArea: A user story or a related issue
Description
Lint explanation
As an opt-in lint, clippy could detect when identifiers (variable/function/struct) names don't spell-check. This feature would be extendable per-project with a glossary/jargonfile, so that the project could define terms for allowable identifiers.
For example, a physics simulation might define dx, fg, tau in their glossary. A process manager may instead define terms like pid, sigint, cwd. Both projects would get to benefit from a glossary that defines the terms of art in their domain, aiding newcomers in comprehension. Clippy would automatically catch not just typoes, but jargon that might be unfamiliar to some contributors to the project.
Example code
let reciever = create_receiver(); // LINT: variable name is misspelled
fn kill_pid(process_id: int) { ... } // LINT: function name contains jargon "pid" which is not defined in glossary
let diameter = r_ball*tau; // okay because r and tau are defined in our glossaryNotes
- To be useful, PascalCase and snake_case identifiers would need to be checked per-word-part. That way
new_piddoes not need a separate definition frompid. - The glossary could live in Cargo.toml or in some other file - it should be encouraged to also define the terms in use.
- I'm not sure where the base wordlist would come from - would it be shipped with clippy?
- Single-letter variables like
i,j,x,ncould be in the default wordlist? Or could just be readily-available to copy-paste into your configuration.
Possible Cargo.toml syntax:
[marker.glossary.terms]
pid = "A process identifier. This is a non-negative integer used to uniquely identify a running process."
cwd = "The current working directory of a process."Metadata
Metadata
Assignees
Labels
A-user-storyArea: A user story or a related issueArea: A user story or a related issue