Skip to content

chore: add cargo-udeps, remove unused deps #263

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

Merged
merged 2 commits into from
Apr 2, 2025

Conversation

Vid201
Copy link
Contributor

@Vid201 Vid201 commented Apr 1, 2025

Good tool to remove unused deps so it doesn't have to be checked manually.

Copy link
Contributor

@KolbyML KolbyML left a comment

Choose a reason for hiding this comment

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

I don't like this approach as it often has a lot of problems like false reports

[package.metadata.cargo-machete]
ignored = ["vergen"]

^ I think this is kind of unidle, that we would need to manually ignore mistakes it makes.

I think we could instead add a CI which runs udeps for example sigp/discv5#179

And I wouldn't want a command like this to be in make lint, I would want the CI to moreso act like an alert that the PR maintainer can then further look into themselves

@Vid201
Copy link
Contributor Author

Vid201 commented Apr 1, 2025

I don't like this approach as it often has a lot of problems like false reports

[package.metadata.cargo-machete]
ignored = ["vergen"]

^ I think this is kind of unidle, that we would need to manually ignore mistakes it makes.

I think we could instead add a CI which runs udeps for example sigp/discv5#179

And I wouldn't want a command like this to be in make lint, I would want the CI to moreso act like an alert that the PR maintainer can then further look into themselves

Okay, it makes sense to have it only in CI.

Lately, I have preferred cargo-machete due to it being much faster, and I've also had problems with cargo-udeps where I had to manually ignore some dependencies. But I'm fine with cargo-udeps as well.

@KolbyML
Copy link
Contributor

KolbyML commented Apr 1, 2025

I don't like this approach as it often has a lot of problems like false reports

[package.metadata.cargo-machete]
ignored = ["vergen"]

^ I think this is kind of unidle, that we would need to manually ignore mistakes it makes.
I think we could instead add a CI which runs udeps for example sigp/discv5#179
And I wouldn't want a command like this to be in make lint, I would want the CI to moreso act like an alert that the PR maintainer can then further look into themselves

Okay, it makes sense to have it only in CI.

Lately, I have preferred cargo-machete due to it being much faster, and I've also had problems with cargo-udeps where I had to manually ignore some dependencies. But I'm fine with cargo-udeps as well.

As long as we don't have an ignore section in our Cargo.tomls I would be fine if you wanted to try cargo-machete in CI, assuming you can make it less strict so we don't need to add ignore sections

@KolbyML
Copy link
Contributor

KolbyML commented Apr 1, 2025

I would also be fine with a solution where we didn't have a CI, but had a make command to run it just, not under lint, then it could be up to the individual to check

@Vid201
Copy link
Contributor Author

Vid201 commented Apr 1, 2025

I just tried cargo +nightly udeps as well, but it doesn't find unused deps well (misses most of them).

With machete, you can also specify ignore deps in the workspace Cargo.toml instead of having to specify in each package Cargo.toml separately.

I guess there are 3 options:

  1. use udeps and miss some unused deps
  2. use machete but we need ignored array in workspace Cargo.toml
  3. leave this for now

@KolbyML
Copy link
Contributor

KolbyML commented Apr 1, 2025

I am fine adding a page to the Ream Book, and an option called make clean-deps, which does a check and doesn't change the files automatically. Then a human can use the tool. I would only be fine with a CI if it was correct or under reported, if it overreported false positives then I would have a problem.

I am pretty against having ignored array in workspace Cargo.toml.

@Vid201 Vid201 requested a review from KolbyML April 2, 2025 08:15
@Vid201 Vid201 changed the title chore: add cargo-machete, remove unused deps chore: add cargo-udeps, remove unused deps Apr 2, 2025
Copy link
Contributor

@KolbyML KolbyML left a comment

Choose a reason for hiding this comment

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

:shipit: looks good

@KolbyML KolbyML added this pull request to the merge queue Apr 2, 2025
Merged via the queue into ReamLabs:master with commit 5875b9d Apr 2, 2025
9 checks passed
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.

2 participants