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

Lint docs tests for unused imports #4570

Open
sffc opened this issue Jan 31, 2024 · 7 comments
Open

Lint docs tests for unused imports #4570

sffc opened this issue Jan 31, 2024 · 7 comments
Labels
blocked A dependency must be resolved before this is actionable C-process Component: Team processes T-docs-tests Type: Code change outside core library

Comments

@sffc
Copy link
Member

sffc commented Jan 31, 2024

I've come across a number of docs tests that have unused imports, which can be confusing to clients and developers.

We should clean up unused imports and then prevent them from being added again.

@Manishearth suggested running docs tests with -D warnings or a flag that causes the docs tests to fail if they have unused imports warnings.

@sffc sffc added T-docs-tests Type: Code change outside core library good first issue Good for newcomers C-process Component: Team processes labels Jan 31, 2024
@robertbastian
Copy link
Member

There are also other lints like unused variables that should definitely be checked.

@Harsh1s
Copy link
Contributor

Harsh1s commented Feb 22, 2024

Hello there! I'd like to work on this issue! Could you please assign this to me?

@robertbastian
Copy link
Member

There you go, let me know if you have any questions!

@Harsh1s
Copy link
Contributor

Harsh1s commented Feb 22, 2024

@robertbastian I'm sorry if I sound dumb, I'm new to the project. Just wanted to confirm something. When you say "docs tests", you mean the tutorials in the docs folder right? Also, if I need to do it for all the languages in the tutorials folder, is it possible to run all the tutorials with '-D warnings' to get error when unused imports exist?

Thanks for your help!

@robertbastian
Copy link
Member

No, docs tests are the code in Rustdoc, i.e. things like this

/// ```
/// use icu::list::*;
/// # use icu::locid::locale;
/// # use writeable::*;
/// let formatteur = ListFormatter::try_new_and_with_length(
/// &locale!("fr").into(),
/// ListLength::Wide,
/// )
/// .unwrap();
/// let pays = ["Italie", "France", "Espagne", "Allemagne"];
///
/// assert_writeable_parts_eq!(
/// formatteur.format(pays.iter()),
/// "Italie, France, Espagne et Allemagne",
/// [
/// (0, 6, parts::ELEMENT),
/// (6, 8, parts::LITERAL),
/// (8, 14, parts::ELEMENT),
/// (14, 16, parts::LITERAL),
/// (16, 23, parts::ELEMENT),
/// (23, 27, parts::LITERAL),
/// (27, 36, parts::ELEMENT),
/// ]
/// );
/// ```
. They are run by this CI job:
[tasks.test-docs]
description = "Run all Rust doctests with all features"
category = "ICU4X Development"
command = "cargo"
args = ["test", "--all-features", "--doc", "--no-fail-fast"]

robertbastian pushed a commit that referenced this issue Feb 27, 2024
Cleaned all the unused imports, which can be confusing to clients and developers.

Part of #4570
@sffc sffc added this to the Priority Backlog ⟨P3⟩ milestone Feb 29, 2024
@sffc
Copy link
Member Author

sffc commented Feb 29, 2024

Fixed by #4628, yes?

@robertbastian
Copy link
Member

I would consider this fixed if we have CI that prevents backsliding.

@robertbastian robertbastian reopened this Feb 29, 2024
@sffc sffc added blocked A dependency must be resolved before this is actionable and removed good first issue Good for newcomers labels Feb 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocked A dependency must be resolved before this is actionable C-process Component: Team processes T-docs-tests Type: Code change outside core library
Projects
None yet
Development

No branches or pull requests

3 participants