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

Warn if error message doesn't conform to style guideline #8172

Open
kangalio opened this issue Dec 26, 2021 · 1 comment
Open

Warn if error message doesn't conform to style guideline #8172

kangalio opened this issue Dec 26, 2021 · 1 comment
Labels
A-lint Area: New lints

Comments

@kangalio
Copy link

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 Display impl on types that have an Error impl
  • .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))?
@kangalio kangalio added the A-lint Area: New lints label Dec 26, 2021
@kangalio
Copy link
Author

Just noticed this suggestion is indirectly included in #1798

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lint Area: New lints
Projects
None yet
Development

No branches or pull requests

1 participant