icu4x icon indicating copy to clipboard operation
icu4x copied to clipboard

Lint docs tests for unused imports

Open sffc opened this issue 1 year ago • 5 comments
trafficstars

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 avatar Jan 31 '24 23:01 sffc

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

robertbastian avatar Feb 20 '24 16:02 robertbastian

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

Harsh1s avatar Feb 22 '24 13:02 Harsh1s

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

robertbastian avatar Feb 22 '24 14:02 robertbastian

@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!

Harsh1s avatar Feb 22 '24 16:02 Harsh1s

No, docs tests are the code in Rustdoc, i.e. things like this https://github.com/unicode-org/icu4x/blob/f4fe3c5f994bc448d21660430c06ab1f429a604d/components/list/src/list_formatter.rs#L97-L121. They are run by this CI job: https://github.com/unicode-org/icu4x/blob/f4fe3c5f994bc448d21660430c06ab1f429a604d/tools/make/tests.toml#L49-L53

robertbastian avatar Feb 22 '24 16:02 robertbastian

Fixed by #4628, yes?

sffc avatar Feb 29 '24 18:02 sffc

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

robertbastian avatar Feb 29 '24 18:02 robertbastian