rust-lang / rust-clippy

A bunch of lints to catch common mistakes and improve your Rust code. Book: https://doc.rust-lang.org/clippy/
https://rust-lang.github.io/rust-clippy/
Other
11.41k stars 1.54k forks source link

Consider publishing `clippy_utils` as a crates.io crate for others to reuse #13556

Open alice-i-cecile opened 2 weeks ago

alice-i-cecile commented 2 weeks ago

Description

Over at the bevy_cli project, we're implementing custom lints for Bevy, and bootstrapping off of Clippy's existing tools :) We'd love to publish this to crates.io so folks can cargo install bevy_cli, but can't do so easily due to clippy_utils only existing as a git dependency.

We don't particularly care about stability or the like: simply publishing whatever you have periodically would be enough.

Prompted by https://github.com/TheBevyFlock/bevy_cli/issues/150

BD103 commented 2 weeks ago

For the period, you could definitely match what Cargo does and publish for every stable release (as long as each release provides what nightly version they were pinned to at that time).

Publishing clippy_utils will also require clippy_config, but that's also reserved on https://crates.io.

Thanks for your consideration!

flip1995 commented 1 week ago

as long as each release provides what nightly version they were pinned to at that time

How would you recommend to best provide this information?

Publishing clippy_utils will also require clippy_config, but that's also reserved on https://crates.io.

Yeah, I made sure that those crates are squatted for us (with me and rust-lang-owner as owners) recently, in anticipation that such a request would come up at some point. I just thought it would be from the dylint maintainers. cc @smoelius

BD103 commented 1 week ago

as long as each release provides what nightly version they were pinned to at that time

How would you recommend to best provide this information?

The channel field within rust-toolchain is enough! :)

If releases are to be automated, you can automatically extract this value using Taplo. I did something very similar in bevy_lint's CI.

flip1995 commented 1 week ago

Offtopic: shouldn't this be

toolchain: ${{ needs.extract-rust-version.outputs.toolchain }}

in your workflow file?


Extracting this in an automated way from the rust-toolchain file is easy. I'd probably just use a grep command though. My question is more: where should I put this information? Just in the README of clippy_utils/clippy_config?

BD103 commented 1 week ago

Offtopic: shouldn't this be

toolchain: ${{ needs.extract-rust-version.outputs.toolchain }}

in your workflow file?

For a second I thought so too, but I rename it in the job outputs:

    outputs:
      channel: ${{ steps.toolchain.outputs.toolchain }}
      components: ${{ steps.toolchain.outputs.components }}

This is confusing, though, so I'll probably change it.

Extracting this in an automated way from the rust-toolchain file is easy. I'd probably just use a grep command though. My question is more: where should I put this information? Just in the README of clippy_utils/clippy_config?

If you use Github Releases, you could add it there. (Maybe also the CHANGELOG.md?)

flip1995 commented 1 week ago

CHANGELOG.md is just for stable and external releases for Clippy itself. Not for something like this. And I'd like to keep it that way.

If we would start using Github releases, I think we would need to copy the whole changelog there every time, so that it is a proper release. I'd rather avoid that.

So I guess, I will add it to the README of the crates, so that it also shows up on the crates.io page when publishing.

BD103 commented 1 week ago

So I guess, I will add it to the README of the crates, so that it also shows up on the crates.io page when publishing.

If that's too much of a hassle, each release is tagged, so I can figure it out using the tagged commit.

flip1995 commented 1 week ago

Let's wait for the clippy meeting where we talk about this. And if we decide that we want to publish it, I'll think about what would work for me and other people involved in releases and would make it easy for you to find the toolchain.

smoelius commented 2 days ago

We'd love to publish this to crates.io so folks can cargo install bevy_cli, but can't do so easily due to clippy_utils only existing as a git dependency.

Won't the user have to specify the toolchain on the command line, e.g.:

cargo +nightly-2024-10-03 install bevy_cli

Or am I missing something?

BD103 commented 2 days ago

Won't the user have to specify the toolchain on the command line, e.g.:

cargo +nightly-2024-10-03 install bevy_cli

Or am I missing something?

You're right, but I still prefer it to --git https://github.com/ TheBevyFlock/bevy_cli --tag lint-v0.1.0 bevy_lint! It's shorter and I trust it more, since unlike tags versions published to crates.io cannot be modified.