Skip to content

Commit

Permalink
checkpatch: warn on empty rust doc comments
Browse files Browse the repository at this point in the history
Add a check to warn if there are consecutive empty `///` lines in rust
files.

Suggested-by: Miguel Ojeda <[email protected]>
Link: Rust-for-Linux#1109
Signed-off-by: Hridesh MG <[email protected]>
  • Loading branch information
hrideshmg authored and intel-lab-lkp committed Sep 11, 2024
1 parent d3e01b6 commit b64a13c
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions scripts/checkpatch.pl
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit b64a13c

Please sign in to comment.