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

Move deny lint checks to script #1641

Merged
merged 1 commit into from Feb 14, 2023

Conversation

Harshil-Jani
Copy link
Contributor

Closes #1551
Signed-off-by: Harshil Jani harshiljani2002@gmail.com

@apoelstra
Copy link
Member

This article which I am coincidentally reading right now suggests just putting RUSTFLAGS=-D warnings across the whole CI script rather than doing one run. (It also has a bunch of other easy to apply suggestions; search "CI Workflow"; but these are unrelated to this PR.)

OTOH I think cargo clippy --all-targets --all-features is likely to accomplish what we want, so I'm happy to ACK this as-is.

@apoelstra
Copy link
Member

BTW it looks like CI is having some sort of network hiccup. I'll kick this in a few hours, or another day.

apoelstra
apoelstra previously approved these changes Feb 10, 2023
Copy link
Member

@apoelstra apoelstra left a comment

Choose a reason for hiding this comment

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

ACK 2ad5ba5

@sanket1729
Copy link
Member

sanket1729 commented Feb 10, 2023

Amongst all the lints that we are deleting, are we losing anything that the compiler would not warn us? Should we make the deny a warn and the CI can then mark the warnings as errors?

@apoelstra
Copy link
Member

Good question. I think missing_docs is not a warning by default, so we should put a warn(missing_docs) back in. But the rest I'm pretty sure are warnings.

@Harshil-Jani
Copy link
Contributor Author

Thanks @apoelstra for the Article (Added to reading list). I have updated the commit. Does it look good now ?

@apoelstra
Copy link
Member

Looks great, thanks!

CI is failing though because we don't have clippy available in all contexts. Could you change test.sh to add the line above the other cargo clippy lines (inside the if "$DO_LINT" block), since we know that clippy is available there?

@apoelstra
Copy link
Member

Could you copy the if syntax from bitcoin/contrib/test.sh which gates the existing cargo clippy invocations?

@apoelstra
Copy link
Member

This is really interesting .... I'm surprised that we can run the examples in the root like this even though the examples actually live in bitcoin/. I wonder what would happen if multiple crates had examples with the same name.

@Harshil-Jani could you either:

  • Add -D warningsto the existing cargo clippy lines and add only a single new cargo clippy --all-targets --all-features line; or
  • Do what you've done, but remove the existing cargo clippy block because it's now redundant

contrib/test.sh Outdated
Comment on lines 5 to 13
if [ "$DO_LINT" = true ]
then
cargo clippy --all-features --all-targets -- -D warnings
cargo clippy --example bip32 -- -D warnings
cargo clippy --example handshake --features=rand-std -- -D warnings
cargo clippy --example ecdsa-psbt --features=bitcoinconsensus -- -D warnings
cargo clippy --example taproot-psbt --features=rand-std,bitcoinconsensus -- -D warnings
fi

Copy link
Member

Choose a reason for hiding this comment

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

We already have these lines in the bitcoin/contrib/test.sh script, what is the purpose of adding them here?

Copy link
Member

Choose a reason for hiding this comment

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

This ones have -D warnings added.

Copy link
Member

Choose a reason for hiding this comment

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

We have -D warnings in bitcoin/contrib/test.sh also

@Harshil-Jani
Copy link
Contributor Author

This is really interesting .... I'm surprised that we can run the examples in the root like this even though the examples actually live in bitcoin/. I wonder what would happen if multiple crates had examples with the same name.

@Harshil-Jani could you either:

  • Add -D warningsto the existing cargo clippy lines and add only a single new cargo clippy --all-targets --all-features line; or
  • Do what you've done, but remove the existing cargo clippy block because it's now redundant

Going ahead with the second implementation.

@apoelstra
Copy link
Member

This looks good to me. Interesting that the --all-targets line was already present in bitcoin/contrib.sh. It definitely looks like it belongs in the top-level contrib.sh. Thanks!

apoelstra
apoelstra previously approved these changes Feb 13, 2023
Copy link
Member

@apoelstra apoelstra left a comment

Choose a reason for hiding this comment

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

ACK 98bfd52

@tcharding
Copy link
Member

I had a play with this. Looks like the explicit linting of the examples is unneeded, and git blame says I'm the goose that added those in the first place :)

As far as I can tell we need no changes to the CI scripts at all in this PR to achieve the closing of the issue we just remove the "coding convention" attributes as is done. The CI scripts in bitcoin, hashes, and internals already have calls to clippy as: cargo clippy --all-features --all-targets -- -D warnings.

@Harshil-Jani
Copy link
Contributor Author

Thankyou @tcharding and @apoelstra for clarity and helping out.

I had a play with this. Looks like the explicit linting of the examples is unneeded, and git blame says I'm the goose that added those in the first place :)

As far as I can tell we need no changes to the CI scripts at all in this PR to achieve the closing of the issue we just remove the "coding convention" attributes as is done. The CI scripts in bitcoin, hashes, and internals already have calls to clippy as: cargo clippy --all-features --all-targets -- -D warnings.

Signed-off-by: Harshil Jani <harshiljani2002@gmail.com>
Copy link
Member

@apoelstra apoelstra left a comment

Choose a reason for hiding this comment

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

ACK a1c3082

Copy link
Collaborator

@Kixunil Kixunil left a comment

Choose a reason for hiding this comment

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

ACK a1c3082

@apoelstra apoelstra merged commit 7930a9b into rust-bitcoin:master Feb 14, 2023
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.

Move #![deny(...)] from lib.rs to CI (script)
5 participants