fix: too_long_first_doc_paragraph suggests wrongly when first line too long (#14276)

Fixes #14274

changelog: [`too_long_first_doc_paragraph`]: fix wrong suggestion when
first line too long
This commit is contained in:
Jason Newcomb 2025-02-24 10:04:01 +00:00 committed by GitHub
commit 0fa170621d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 21 additions and 1 deletions

View file

@ -51,7 +51,11 @@ pub(super) fn check(
// We make this suggestion only if the first doc line ends with a punctuation
// because it might just need to add an empty line with `///`.
should_suggest_empty_doc = doc.ends_with('.') || doc.ends_with('!') || doc.ends_with('?');
} else if spans.len() == 2 {
// We make this suggestion only if the second doc line is not empty.
should_suggest_empty_doc &= !doc.is_empty();
}
let len = doc.chars().count();
if len >= first_paragraph_len {
break;