lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ab5a84a40a5bf73001cd35f6f9108830ff70c5ee.camel@perches.com>
Date: Fri, 13 Sep 2024 12:21:41 -0700
From: Joe Perches <joe@...ches.com>
To: Alice Ryhl <aliceryhl@...gle.com>, Patrick Miller <paddymills@...ton.me>
Cc: a.hindborg@...sung.com, alex.gaynor@...il.com, apw@...onical.com, 
	benno.lossin@...ton.me, bjorn3_gh@...tonmail.com, boqun.feng@...il.com, 
	dwaipayanray1@...il.com, gary@...yguo.net, linux-kernel@...r.kernel.org, 
	lukas.bulwahn@...il.com, ojeda@...nel.org, rust-for-linux@...r.kernel.org, 
	tmgross@...ch.edu, wedsonaf@...il.com
Subject: Re: [PATCH v3 2/2] checkpatch: warn on known non-plural rust doc
 headers

On Fri, 2024-09-13 at 09:33 +0200, Alice Ryhl wrote:
> On Thu, Sep 12, 2024 at 9:57 PM Patrick Miller <paddymills@...ton.me> wrote:
> > 
> > Adds a check for documentation in rust file. Warns if certain known
> > documentation headers are not plural.
> > 
> > The rust maintainers prefer document headers to be plural. This is to enforce
> > consistency among the documentation as well as to protect against errors when
> > additions are made. For example, if the header said "Example" because there was
> > only 1 example, if a second example was added, making the header plural could
> > easily be missed and the maintainers prefer to not have to remind people to fix
> > their documentation.
> > 
> > Link: https://github.com/Rust-for-Linux/linux/issues/1110
> > 
> > v1: https://lore.kernel.org/rust-for-linux/2024090628-bankable-refusal-5f20@gregkh/T/#t
> > v2: https://lore.kernel.org/rust-for-linux/92be0b48-cde9-4241-8ef9-7fe4d7c42466@proton.me/T/#t
> >   - fixed whitespace that was formatted due to editor settings
> > v3:
> >   - move && to previous line and remove whitespace in WARN per Joe Perches
> >   - reformat following C coding style
> > ---
> >  scripts/checkpatch.pl | 7 ++++
> > +++
> >  1 file changed, 7 insertions(+)
> 
> This is missing your Signed-off-by and the changelog should be below
> the --- line so it doesn't get included in the changelog when applied.
[]
> > diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
[]
> > @@ -3900,6 +3900,13 @@ sub process {
> >                              "Avoid using '.L' prefixed local symbol names for denoting a range of code via 'SYM_*_START/END' annotations; see Documentation/core-api/asm-annotations.rst\n" . $herecurr);
> >                 }
> > 
> > +# check that document section headers are plural in rust files
> > +               if ($realfile =~ /\.rs$/ &&
> > +                   $rawline =~ /^\+\s*\/\/\/\s+#+\s+(Example|Invariant|Guarantee|Panic)\s*$/) {
> > +                       WARN("RUST_DOC_HEADER",
> > +                            "Rust doc headers should be plural\n" . $herecurr);

While OK my suggestion would be to add a $fix option
and be case insensitive

		if ($realfile =~ /\.rs$/ &&
		    $rawline =~ /^\+\s*\/\/\/\s+#+\s+(Example|Invariant|Guarantee|Panic)\s*$/i) {
			if (WARN("RUST_DOC_HEADER",
	                       	 "Rust doc header '$1' should be plural\n" . $herecurr) &&
			    $fix) {
				$fixed[$fixlinenr] = s/\b$1\b/ucfirst(lc($1))/e;
			}

And if there are going to be more rust specific tests,
there should be a rust specific block to avoid continual
tests of $realfile =~ /\.rs$/


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ