Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Detect documentation that is empty #9931

Closed
i509VCB opened this issue Nov 23, 2022 · 10 comments · Fixed by #12342
Closed

Detect documentation that is empty #9931

i509VCB opened this issue Nov 23, 2022 · 10 comments · Fixed by #12342
Assignees
Labels
A-lint Area: New lints good-first-issue These issues are a good way to get started with Clippy

Comments

@i509VCB
Copy link
Contributor

i509VCB commented Nov 23, 2022

What it does

Detects documentation that is empty.

Lint Name

empty-docs

Category

suspicious

Advantage

  • Empty docs are often pointless
  • The developer may have forgotten to fill in the documentation.

Drawbacks

  • Could result in the commonly used missing_docs lint being fired. However it should be possible to just use the attribute #[allow(missing_docs)] where needed.
  • If #[forbid(missing_docs] is enabled, removing the empty doc comments will fire the lint.
  • What applies as "empty documentation" would need to consider whitespace and possibly odd characters. Using str::is_whitespace would probably satisfy that case.

Example

//!

Could be written as (if #![warn(missing_docs)] or #![deny(missing_docs)]):

#![allow(missing_docs)]

or a message:

help: fill in the documentation

Could be written as (if missing_docs is not enabled)

If #[forbid(missing_docs)], then we probably should advise changing forbid to deny or show the message to fill in the documentation.

@i509VCB i509VCB added the A-lint Area: New lints label Nov 23, 2022
@xFrednet
Copy link
Member

@rustbot label +good-first-issue

@rustbot rustbot added the good-first-issue These issues are a good way to get started with Clippy label Nov 27, 2022
@cgorski
Copy link

cgorski commented Dec 23, 2022

@rustbot claim

@cgorski
Copy link

cgorski commented Jan 3, 2023

I just submitted a pull request in #10152 with my initial attempt at this. I do Rust dev daily for private work, but this is my first time contributing to the project, so please have mercy.

I believe I have successfully addressed blank /// doc strings and `#[doc("")] attributes by grouping attributes together that are attached to various items, and then looking for groups that are all blank.

I have not addressed the //! blank strings as I am not certain how to fetch this item from the syntax tree at the top level. It does not seem to appear with check_item(). I have not tested it inside other structures.

I have not tested any other forms of doc strings either.

I'm looking for:

  1. A general assessment of what I did and if it is on the right path to completely and correctly implementing the issue
  2. Suggestions on how I could detect //! best within the current framework of what I am doing (or any framework for that matter)

Thanks, I'm excited to help out on this, looking for lots of constructive criticism.

@cgorski
Copy link

cgorski commented Jan 3, 2023

Looks like there are more cases for me to handle within functions.

I just noticed I checked in two config files that have local-specific changes - I'll make sure to remove those for the final PR.

@SET001
Copy link

SET001 commented Oct 6, 2023

@cgorski are you still working on it? If no then I can try to pick it up.

@tgross35
Copy link
Contributor

tgross35 commented Oct 6, 2023

Honestly, I'd call it a bit surprising that //! is suitable enough to satisfy missing_docs, I'd still call that missing. Maybe we could make empty_docs an automatic warn if missing_docs is on, with eventual plans to merge them

@SET001
Copy link

SET001 commented Oct 6, 2023

@rustbot claim

@SET001
Copy link

SET001 commented Oct 6, 2023

taking into account this - should #[doc("")] be out of scope for this lint?

@SET001 SET001 mentioned this issue Oct 6, 2023
@lucarlig
Copy link
Contributor

@rustbot claim

@rustbot rustbot assigned lucarlig and unassigned SET001 Feb 24, 2024
@lucarlig lucarlig mentioned this issue Feb 24, 2024
@bors bors closed this as completed in 1c50948 Feb 26, 2024
@Dovchik
Copy link

Dovchik commented Aug 6, 2024

cargo clippy --fix doesn't not clean https://rust-lang.github.io/rust-clippy/master/index.html#/empty_docs
Should I report it as an issue or it's expected?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lint Area: New lints good-first-issue These issues are a good way to get started with Clippy
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants