Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lint - spellcheck with project-specific wordlist/glossary #50

Open
fwip opened this issue Oct 9, 2024 · 1 comment
Open

Lint - spellcheck with project-specific wordlist/glossary #50

fwip opened this issue Oct 9, 2024 · 1 comment
Labels
A-user-story Area: A user story or a related issue

Comments

@fwip
Copy link

fwip commented Oct 9, 2024

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 glossary

Notes

  • To be useful, PascalCase and snake_case identifiers would need to be checked per-word-part. That way new_pid does not need a separate definition from pid.
  • 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, n could 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."
@fwip fwip added the A-user-story Area: A user story or a related issue label Oct 9, 2024
@jhpratt
Copy link
Member

jhpratt commented Oct 9, 2024

Was this intended to be opened here? This isn't the repository for clippy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-user-story Area: A user story or a related issue
Projects
None yet
Development

No branches or pull requests

2 participants