From: Arnaud Lecomte <contact@arnaud-lcm.com>
To: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>
Cc: "Andy Whitcroft" <apw@canonical.com>,
"Joe Perches" <joe@perches.com>,
"Dwaipayan Ray" <dwaipayanray1@gmail.com>,
"Lukas Bulwahn" <lukas.bulwahn@gmail.com>,
"Miguel Ojeda" <ojeda@kernel.org>,
"Alex Gaynor" <alex.gaynor@gmail.com>,
"Boqun Feng" <boqun.feng@gmail.com>,
"Gary Guo" <gary@garyguo.net>,
"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
"Benno Lossin" <benno.lossin@proton.me>,
"Andreas Hindborg" <a.hindborg@kernel.org>,
"Alice Ryhl" <aliceryhl@google.com>,
"Trevor Gross" <tmgross@umich.edu>,
"Danilo Krummrich" <dakr@kernel.org>,
"Nathan Chancellor" <nathan@kernel.org>,
"Nick Desaulniers" <nick.desaulniers+lkml@gmail.com>,
"Bill Wendling" <morbo@google.com>,
"Justin Stitt" <justinstitt@google.com>,
linux-kernel@vger.kernel.org, rust-for-linux@vger.kernel.org,
llvm@lists.linux.dev, skhan@linuxfoundation.org
Subject: Re: [PATCH v3 1/2] checkpatch.pl: warn about // comments on private Rust items
Date: Tue, 22 Apr 2025 16:37:46 +0200 [thread overview]
Message-ID: <06dde2dd-5d88-49d4-9e46-72a2e12ab1c2@arnaud-lcm.com> (raw)
In-Reply-To: <CANiq72n41Oj4K-yZCWbNXJQEEjTqjXHYgrkffAg_mUg8dKLWQg@mail.gmail.com>
On 22/04/2025 15:46, Miguel Ojeda wrote:
> On Tue, Apr 22, 2025 at 2:58 PM Arnaud Lecomte <contact@arnaud-lcm.com> wrote:
>> The detection uses multiple heuristics to identify likely doc comments:
>> - Comments containing markdown
> Markdown is required in both documentation and comments, so I don't
> think we can use some of those, e.g. inline code spans (i.e.
> backticks) are common (and actually expected) in comments. Something
> like a title (i.e. `#`) or intra-doc links are uncommon, though.
Let's then maybe reduce the score of this heuristic and remove intra-doc
links and titles detection. After reviewing, it indeed doesn't really
make sense.
>> - Comments starting with an imperative tone
> Some people document using the third-person, e.g. some functions say
> "Returns ..." like you have below. (It is not easy to enforce
> kernel-wide a single style here, thus so far we don't.)
>
> (Looking briefly at the code) Ah, I think you are covering both, good.
As mentioned earlier, we can reduce the score of any heuristic which
could lead to any important false positive.
In my opinion, as long as the heuristic is relevant, we always have the
possibility to diminish the score associated with the heuristic, hence
preventing unnecessary false positives.
>> - Comments with references: @see, @link, ...
> Do you mean Markdown references? Or javadoc-like ones?
>
> (Looking again at the code...) I think you are referring to actually
> strings like `@see`. Hmm... I don't think we have those -- the only
> `@` I would expect in a comment are thinks like emails or the
> `rustdoc` syntax to disambiguate the "kind" of item, e.g.
> `type@NotThreadSafe`. I do see a `@maxlen` somewhere, but that should
> have been an inline code span, and anyway it is not a `@see` or
> `@link`. But I may be confused here?
>
I think that you are definitely more experienced with what's done
commonly in rust code. Let's maybe change this heuristic definition with
@ related to types or some other annotation. Do you have some example I
could have a look to come in the next version with a relevant list of @
we can encounter.
>> Comments are only flagged if they:
>> - Appear above private items
>> - Don't contain obvious non-doc patterns (TODO, FIXME)
>> - Score sufficiently on heuristics
> Nice work! I wasn't expecting something with actual weighted scoring,
> but if the maintainers are OK with something as involved as that, then
> I guess it is fine. We may need to tweak the scoring in the future,
> but it may be a good experiment.
I think it is a nice approach due to the granularity it offers. This
will drastically reduce the number of false positives.
> Thanks!
>
> Cheers,
> Miguel
Thanks for your feedbacks,
Arnaud
next prev parent reply other threads:[~2025-04-22 14:37 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-22 12:56 [PATCH v3 0/2] checkpatch.pl: Add warning for " Arnaud Lecomte
2025-04-22 12:58 ` [PATCH v3 1/2] checkpatch.pl: warn about " Arnaud Lecomte
2025-04-22 13:46 ` Miguel Ojeda
2025-04-22 14:37 ` Arnaud Lecomte [this message]
2025-04-22 15:32 ` Miguel Ojeda
2025-04-23 11:33 ` Arnaud Lecomte
2025-05-23 7:15 ` Arnaud Lecomte
2025-04-22 12:58 ` [PATCH v3 3/3] checkpatch.pl: --fix support for `//` comments rust private items Arnaud Lecomte
2025-04-22 13:02 ` [PATCH v3 2/2 resend] " Arnaud Lecomte
2025-04-22 14:10 ` [PATCH v3 0/2] checkpatch.pl: Add warning for // comments on private Rust items Miguel Ojeda
2025-04-22 14:38 ` Arnaud Lecomte
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=06dde2dd-5d88-49d4-9e46-72a2e12ab1c2@arnaud-lcm.com \
--to=contact@arnaud-lcm.com \
--cc=a.hindborg@kernel.org \
--cc=alex.gaynor@gmail.com \
--cc=aliceryhl@google.com \
--cc=apw@canonical.com \
--cc=benno.lossin@proton.me \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun.feng@gmail.com \
--cc=dakr@kernel.org \
--cc=dwaipayanray1@gmail.com \
--cc=gary@garyguo.net \
--cc=joe@perches.com \
--cc=justinstitt@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=llvm@lists.linux.dev \
--cc=lukas.bulwahn@gmail.com \
--cc=miguel.ojeda.sandonis@gmail.com \
--cc=morbo@google.com \
--cc=nathan@kernel.org \
--cc=nick.desaulniers+lkml@gmail.com \
--cc=ojeda@kernel.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=skhan@linuxfoundation.org \
--cc=tmgross@umich.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®