[PATCH v3 2/2 RESEND] checkpatch: warn on empty rust doc comments
From: Hridesh MG
Date: Sun Sep 29 2024 - 07:16:09 EST
Add a check to warn if there are consecutive empty `///` lines in rust
files.
Suggested-by: Miguel Ojeda <ojeda@xxxxxxxxxx>
Link: https://github.com/Rust-for-Linux/linux/issues/1109
Signed-off-by: Hridesh MG <hridesh699@xxxxxxxxx>
---
No changes in v2, this is a new patch
No changes in v3
---
scripts/checkpatch.pl | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 39032224d504..c75bc3927bf6 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -3884,6 +3884,13 @@ sub process {
}
}
+# check for consecutive empty /// lines in .rs files
+ if ($realfile =~ /\.rs$/ &&
+ $rawline =~ /^\+\s*\/\/\/$/ && $prevrawline =~ /^\+\s*\/\/\/$/) {
+ WARN("RUST_DOC_EMPTY",
+ "avoid using consecutive empty rustdoc comments\n" . $herecurr);
+ }
+
# check for adding lines without a newline.
if ($line =~ /^\+/ && defined $lines[$linenr] && $lines[$linenr] =~ /^\\ No newline at end of file/) {
if (WARN("MISSING_EOF_NEWLINE",
--
2.46.1