Skip to content

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

@fwip

Description

@fwip

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."

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-user-storyArea: A user story or a related issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions