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

dev: run cargo clippy --all -- -W clippy::all -W clippy::pedantic -W clippy::restriction -W clippy::nursery -D warnings and fix the repo, then add this command in the CI #584

Closed
3 tasks
Eikix opened this issue Sep 22, 2023 · 13 comments
Labels
enhancement Enhancement of the code, not introducing new features.

Comments

@Eikix
Copy link
Member

Eikix commented Sep 22, 2023

Describe the enhancement request

Describe Preferred Solution

Tasks

@Eikix Eikix added the enhancement Enhancement of the code, not introducing new features. label Sep 22, 2023
@bhavyagosai
Copy link
Contributor

hey can I take this up?

@Eikix
Copy link
Member Author

Eikix commented Nov 19, 2023

Sure!
If the result of this command is huge (as in lots of comments by clippy), be sure to discuss in this issue's discussion which fixes to implement first. Don't be scared to split the fixes into multiple PRs.
Finally, if you can find a way for everyone to have a strict clippy, that'd be great, for instance the strictest clippy.toml file.

@bhavyagosai
Copy link
Contributor

yes there are alot of lints there, i am starting with clippy::nursery. also some of the lints have suggestions which are breaking changes so for now i am just fixing things that are non-breaking changes.

@bhavyagosai
Copy link
Contributor

added a PR for clippy::nursery lints, it still contains some lints but they might require breaking changes so will do them in the end

@bhavyagosai
Copy link
Contributor

in clippy::pedantic there are many lints which are related to doc comments. For example, missing # Panic, # Returns etc sections. What should be done regarding them?

@Eikix
Copy link
Member Author

Eikix commented Nov 19, 2023

in clippy::pedantic there are many lints which are related to doc comments. For example, missing # Panic, # Returns etc sections. What should be done regarding them?

I think if a test util can panic (meaning it's under a cfg test), it's not worth adding the # panic rustdoc,
If not, I think it's worth it

@Eikix
Copy link
Member Author

Eikix commented Nov 19, 2023

added a PR for clippy::nursery lints, it still contains some lints but they might require breaking changes so will do them in the end

What do you mean breaking chage?

@bhavyagosai
Copy link
Contributor

added a PR for clippy::nursery lints, it still contains some lints but they might require breaking changes so will do them in the end

What do you mean breaking chage?

haven't look too deep but i was seeing lints saying Future needs to be Send, some functions that where async need not to be async, a From was suggested to be converted into TryFrom, etc...

so for now i am doing ones that are straight forward and i know for sure that doesn't affect public API

@bhavyagosai
Copy link
Contributor

also according to docs we shouldn't enable this lint groups completely since they can contain many false positives and we would need to use alot of #[allow] everywhere. we should only whitelist lints from those group where they are necessary.

for example see this lint, it even says in the comment doing this is not idiomatic rust code. I checked other projects and none seem to be using them. For CI i think we can follow what starkware-libs/cairo does https://github.com/starkware-libs/cairo/blob/main/scripts/clippy.sh

what do you think @Eikix?

@Eikix
Copy link
Member Author

Eikix commented Nov 19, 2023

also according to docs we shouldn't enable this lint groups completely since they can contain many false positives and we would need to use alot of #[allow] everywhere. we should only whitelist lints from those group where they are necessary.

for example see this lint, it even says in the comment doing this is not idiomatic rust code. I checked other projects and none seem to be using them. For CI i think we can follow what starkware-libs/cairo does https://github.com/starkware-libs/cairo/blob/main/scripts/clippy.sh

what do you think @Eikix?

Great idea! Is idiomatic rust 2018 the latest version?
But regardless it's a great idea,
Why integrate it in a .sh file though? Can't we use clippy.toml to dictate the behaviour?

@bhavyagosai
Copy link
Contributor

bhavyagosai commented Nov 20, 2023

Is idiomatic rust 2018 the latest version?

I think latest is 2021

Why integrate it in a .sh file though? Can't we use clippy.toml to dictate the behaviour?

afaik just so new contributors can run it easily and don't need to remove it, or even add that to git hooks.

@Eikix
Copy link
Member Author

Eikix commented Nov 20, 2023

Is idiomatic rust 2018 the latest version?

I think latest is 2021

We can do 2021 if it makes sense for us

Why integrate it in a .sh file though? Can't we use clippy.toml to dictate the behaviour?

afaik just so new contributors can run it easily and don't need to remove it, or even add that to git hooks.

Mmh I'd think clippy.toml file feels sounder (+ CI checks we already have afaik)

@bhavyagosai
Copy link
Contributor

bhavyagosai commented Nov 20, 2023

We can do 2021 if it makes sense for us

just checked there is no rust-2021-idioms

Mmh I'd think clippy.toml file feels sounder

i don't think clippy.toml file can be used to enable or disable lints, clippy docs also suggests using flags.

There is rust-lang/cargo#12115 that got recently merged, but using it would require everyone to have latest rust version.

(+ CI checks we already have afaik)

currently CI uses:

cargo clippy --workspace --all-features --all-targets -- -D warnings

but we should also add -D future-incompatible -D nonstandard-style -D rust-2018-idioms -D rust-2021-compatibility -D unused flags as well in CI. and maybe clippy::nursery once Future related llnts are resolved.

@bhavyagosai bhavyagosai mentioned this issue Nov 20, 2023
8 tasks
@Eikix Eikix closed this as completed Jan 5, 2024
anukkrit149 pushed a commit to karnotxyz/kakarot-rpc that referenced this issue Aug 9, 2024
<!--- Please provide a general summary of your changes in the title
above -->

<!-- Give an estimate of the time you spent on this PR in terms of work
days. Did you spend 0.5 days on this PR or rather 2 days? -->

Time spent on this PR: .2

## Pull request type

<!-- Please try to limit your pull request to one type, submit multiple
pull requests if needed. -->

Please check the type of change your PR introduces:

- [ ] Bugfix
- [X] Feature
- [ ] Code style update (formatting, renaming)
- [ ] Refactoring (no functional changes, no api changes)
- [ ] Build related changes
- [ ] Documentation content changes
- [ ] Other (please describe):

## What is the current behavior?

An absence of the push0 opcode

Resolves kkrt-labs#584 

## What is the new behavior?

push0 opcode at instruction 5f

-
-
-

## Other information

- implements test cases as described:
https://eips.ethereum.org/EIPS/eip-3855
- the stackoverflow error throws at length 1026, as opposed to 1025
- gas cost for op0 is 2, i added a small bit to fit it into the
structure of `exec_push_i`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Enhancement of the code, not introducing new features.
Projects
Archived in project
Development

No branches or pull requests

2 participants