rust-lang / rust-lang/rust-clippy
Warn if error message doesn't conform to style guideline
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 13.5k
- Forks
- 2.2k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 32
Description
What it does
According to the Rust API Guidelines:
The error message given by the Display representation of an error type should be lowercase without trailing punctuation, and typically concise.
Clippy could make sure that error message are lowercase without trailing punctuation, by checking
- the
Displayimpl on types that have anErrorimpl .ok_or("error message"),.map_err(|_| "error message")and similar methods
Lint Name
misformatted_error_message
Category
style
Advantage
An error message that conforms to the official guidelines fits more easily into the ecosystem
Drawbacks
No response
Example
.ok_or_else(|| format!("Unknown wifescore or grade `{}`!", threshold_str))?
Could be written as:
.ok_or_else(|| format!("unknown wifescore or grade `{}`", threshold_str))?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Display impl and Error impl cases, then examine the ok_or, map_err, and ok_or_else examples described in the issue. Define the lint's supported error-message forms and verify that it identifies messages that are not lowercase or that have trailing punctuation, while accepting conforming messages.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- devtools
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100