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

Fix case where doc_markdown is triggered on words ending with "ified" #13163

Merged
merged 2 commits into from
Aug 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions clippy_lints/src/doc/markdown.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@ fn check_word(cx: &LateContext<'_>, word: &str, span: Span, code_level: isize, b
&& matches!(prefix.chars().last(), Some('S' | 'X'))
{
prefix
} else if let Some(prefix) = s.strip_suffix("ified")
&& prefix.chars().all(|c| c.is_ascii_uppercase())
{
prefix
} else {
s.strip_suffix('s').unwrap_or(s)
};
Expand Down
13 changes: 13 additions & 0 deletions tests/ui/doc/doc_markdown-issue_13097.fixed
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// This test checks that words starting with capital letters and ending with "ified" don't
// trigger the lint.

#![deny(clippy::doc_markdown)]

pub enum OutputFormat {
/// `HumaNified`
//~^ ERROR: item in documentation is missing backticks
Plain,
// Should not warn!
/// JSONified console output
Json,
}
13 changes: 13 additions & 0 deletions tests/ui/doc/doc_markdown-issue_13097.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// This test checks that words starting with capital letters and ending with "ified" don't
// trigger the lint.

#![deny(clippy::doc_markdown)]

pub enum OutputFormat {
/// HumaNified
//~^ ERROR: item in documentation is missing backticks
Plain,
// Should not warn!
/// JSONified console output
Json,
}
18 changes: 18 additions & 0 deletions tests/ui/doc/doc_markdown-issue_13097.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
error: item in documentation is missing backticks
--> tests/ui/doc/doc_markdown-issue_13097.rs:7:9
|
LL | /// HumaNified
| ^^^^^^^^^^
|
note: the lint level is defined here
--> tests/ui/doc/doc_markdown-issue_13097.rs:4:9
|
LL | #![deny(clippy::doc_markdown)]
| ^^^^^^^^^^^^^^^^^^^^
help: try
|
LL | /// `HumaNified`
| ~~~~~~~~~~~~

error: aborting due to 1 previous error