Skip to content

Conversation

phip1611
Copy link
Member

@phip1611 phip1611 commented Aug 12, 2021

  • add clippy check as required
  • add rustfmt check as required
  • add rustdoc check as required (#![deny(rustdoc::all)] works since stable 1.52.0)

To improve and enforce code quality.

I'm not sure if we still use Travis CI.

What's your opinion on this @Caduser2020 @IsaacWoods ?

@phip1611 phip1611 self-assigned this Aug 12, 2021
@phip1611 phip1611 requested review from a user and IsaacWoods August 12, 2021 05:20
@@ -11,11 +11,10 @@ use core::marker::PhantomData;
pub const MULTIBOOT2_BOOTLOADER_MAGIC: u32 = 0x36d76289;

/// Possible types of a Tag in the Multiboot2 Information Structure (MBI), therefore the value
/// of the the `typ` field in [`Tag`]. The names and values are taken from the example C code
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tag is private, therefore rustdoc failure

@phip1611 phip1611 changed the title stricter code quality CI checks (clippy, rustfmt) stricter code quality CI checks (clippy, rustfmt, rustdoc) Aug 12, 2021
@phip1611 phip1611 force-pushed the stricter-code-quality-ci branch from 76acf68 to e7a4910 Compare August 12, 2021 05:33
@IsaacWoods
Copy link
Member

Hmm, I've tried having these sorts of checks in CI with communal projects before, and I think I'm generally against it. It makes merging every PR, especially from new contributors, a bit of an uphill battle that doesn't leave a good impression for potential contributors. I think with a relatively small project, doing a clippy PR every so often, as well as manually asking for really bad formatting to be run through rustfmt before you merge is good enough. Open to alternative views though.

I'm not sure if we still use Travis CI.

Ah no, my mistake. Afaik, Travis CI is basically dead (it stopped reporting status updates for this repo ages ago). I fixed that by moving us oven to Actions, but must've forgotten to delete the Travis files. Feel free to remove them :)

@phip1611
Copy link
Member Author

@IsaacWoods

It makes merging every PR, especially from new contributors, a bit of an uphill battle that doesn't leave a good impression for potential contributors

Hm. On the one hand I can understand this. On the otherhand, I'm certain that contributors of Multboot2, which is not a super basic domain but deep into OS development, will also not be total Rust newbees. Furthermore, it's a good opportunity for them to learn to use rust fmt and rust clippy.

Any other opinion? @Caduser2020 @phil-opp

@phip1611
Copy link
Member Author

Any update here @Caduser2020 @phil-opp @IsaacWoods ?

@IsaacWoods
Copy link
Member

I stand by my view that this has more disadvantages than advantages, and that CI failures for slight differences in code style are generally unhelpful (this is especially bad in OSdev when lots of people are a few nightlies behind, and so rustfmt complains not because you didn't format, but you formatted with the wrong version of it). Lots of people's editors autoformat, and I'd rather ask for an individual PR to be reformatted if I felt that the style was confusing or egregious. I also think that it generally annoys people, newbees and otherwise, and most people become exposed to those tools anyway.

So my vote is to close, but I'm also not going to make this a hill to die on, so if you feel particularly strongly, you can merge.

@phip1611
Copy link
Member Author

phip1611 commented Sep 12, 2021

I stand by my view that this has more disadvantages than advantages, and that CI failures for slight differences in code style are generally unhelpful (this is especially bad in OSdev when lots of people are a few nightlies behind, and so rustfmt complains not because you didn't format, but you formatted with the wrong version of it

@IsaacWoods

Theoretically, we could use a "rust-toolchain.toml" to prevent that :)

But I do not insist on the CI requirement. I like it for private projects but will remove it here. Will keep the formatting and style improvements, tho. After that I can finally start with the multiboot2-header crate.. took a little bit longer :)

@phil-opp
Copy link
Member

Any other opinion? @phil-opp

First of all, I'm not maintaining the multiboot2 crate anymore, so my opinion on this doesn't really matter :D.

I don't think that it's a good idea to do add #![deny(clippy::all)] or #![deny(rustdoc::all)] to the code. The problem is that new clippy/rustdoc versions sometimes introduce new warnings, which would then break everyone who depends on this library. It's better to pass the deny argument on the command line in the CI script.

My personal preference is to keep warnings as warnings and use e.g. https://github.com/actions-rs/cargo to show the warnings in the "Files Changed" tab on GitHub. This way, the maintainers can decide whether the warning should be fixed or not, and it doesn't affect the mergeability of newcomer PRs.

Enforcing rustfmt is ok in my opinion, but I agree with @IsaacWoods that doing it on a crate that targets both stable and nightly can lead to problems. If you decide to add such a check, I would again recommend to create a separate CI job for it, which is not required to pass. This way, formatting problems don't block merging of newcomer PRs (they should still be fixed in a follow-up PR though).

@phip1611
Copy link
Member Author

I would again recommend to create a separate CI job for it, which is not required to pass. This way, formatting problems don't block merging of newcomer PRs (they should still be fixed in a follow-up PR though).

I agree, let's do it that way :)

@ghost
Copy link

ghost commented Sep 13, 2021

I agree with @IsaacWoods for this. My build of rust is often a few days behind and rustfmt would become out of sync. I am okay with fixes for these warnings, but breaking CI is not worth it. Vote to close.

@phip1611 phip1611 force-pushed the stricter-code-quality-ci branch from e7a4910 to 198a0c3 Compare October 1, 2021 06:31
@phip1611 phip1611 changed the title stricter code quality CI checks (clippy, rustfmt, rustdoc) Code style improvements + optional CI job(clippy, rustfmt, rustdoc) Oct 1, 2021
@phip1611 phip1611 changed the title Code style improvements + optional CI job(clippy, rustfmt, rustdoc) Code style improvements + optional CI job (clippy, rustfmt, rustdoc) Oct 1, 2021
@phip1611 phip1611 force-pushed the stricter-code-quality-ci branch from 198a0c3 to b2aa888 Compare October 1, 2021 06:33
This commit
- introduces sensible style checks as optional CI tasks,
- removes Travis CI
- applies a few code style fixes
@phip1611 phip1611 force-pushed the stricter-code-quality-ci branch from b2aa888 to 70d3a60 Compare October 1, 2021 06:34
@phip1611
Copy link
Member Author

phip1611 commented Oct 1, 2021

After all, this commit/PR

  • introduces sensible style checks as optional CI task,
  • removes Travis CI, and
  • applies a few code style fixes.

The new CI job should be optional by default, because I think one has to manually mark them as required for PRs.

@phip1611 phip1611 merged commit 946196c into main Oct 1, 2021
@phip1611 phip1611 deleted the stricter-code-quality-ci branch October 1, 2021 06:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants