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

[WIP] [Refactor] Defining clippy rules #91

Merged
merged 14 commits into from
Dec 4, 2023

Conversation

JulesGuesnon
Copy link
Contributor

Description

This PR aims to define standards for clippy, and fixes the too_many_arugment error as well.

About clippy

Imo the best strategy is to use #![deny(clippy::all)] which is covering the most important linting rules, and to cherry pick some of clippy::pedantic as using everything can be painful, and raise false positives.

List of all the pedantic lintings

Example of some pendantic linting I think may be nice to have:

Comment on lines 11 to 12
// TODO: Remove when fixed
clippy::result_unit_err
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added this one to by pass the Result<_, ()> linting as it needs more than a refactor I think

@kaleidawave kaleidawave added the internal-improvements Related to internal publishing, building, workflows, formatting & linting label Nov 27, 2023
@kaleidawave
Copy link
Owner

Awesome! looking good. Great addition to wrap a bunch of arguments to function calling. I always got a bit mixed up with which one was which, so that's a great fix.

With the Result<> issue, I have opened #92 that outlines where that is ATM. Can add an allow for now linking to the issue.

Also subtyping, probably best to add allow for now. The setup might change in the future.

If you want to do the change to the checkers PropertyKey::String to include privacy then that would be great. If it is too complicated then could add allow for now and add a comment that links to the comment I added on #88.

The tighter requirements seem great, going through the clippy page you linked and I think blocking them all by default will improve the codebase now it is getting more mature. You can update the line here to reflect that #![deny(clippy::all)] is not on by default

- Use `cargo clippy` as guidance for design but warning lints are not a blocker

@JulesGuesnon
Copy link
Contributor Author

Hey! About Publicity I'll be glad to do the change, but as it looks likes it involves a lot of noise, I'll do it in another PR I think.

Also about: fn synthesise_function_annotation(...) in checker/src/synthesis/functions.rs there's a lot of TODO above, so it might not be that useful to refactor args into a struct right?

@JulesGuesnon
Copy link
Contributor Author

JulesGuesnon commented Nov 28, 2023

Btw, so you're aware of what clippy::pedantic represents, only in checker it's ~483 errors appearing, so it'll take some time to be compliant, but would for sure allow a higher quality code

checker/src/lib.rs Outdated Show resolved Hide resolved
checker/src/lib.rs Outdated Show resolved Hide resolved
@JulesGuesnon JulesGuesnon marked this pull request as ready for review November 29, 2023 13:50
@kaleidawave
Copy link
Owner

Nice! Cool that it uncovered a bug in the parser as well.

It is great that you have solved a lot of the current lints. For the 'pedantic' level lints it probably best to prioritise those changes until after 0.1 https://github.com/kaleidawave/ezno/milestone/1

Will check out the changes and merge on Friday when I have the time to go through it 👍

Copy link
Owner

@kaleidawave kaleidawave left a comment

Choose a reason for hiding this comment

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

Wow, that is a lot of changes

Some really good changes in here 😍 cleans up a lot of unnecessary code!

Left a few comments. Happy to merge as is, but wondered about some things :)

@@ -63,13 +63,14 @@ fn markdown_lines_append_test_to_rust(
let blocks = {
let mut blocks = Vec::new();
let mut current_filename = None;
while let Some((_, line)) = lines.next() {
for (_, line) in lines.by_ref() {
Copy link
Owner

Choose a reason for hiding this comment

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

Nice! I have used .by_ref() on iterator methods that consume brefore. Didn't know it could be used in the case where you don't want for to consume 👍

}

#[must_use]
Copy link
Owner

Choose a reason for hiding this comment

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

Interesting. I haven't had much experience with #[must_use]. Is there a heuristic for when to it is needed? Was there any code that didn't use this result?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

According to this (old) reddit post by one of clippy maintainer here is how they decide which function should be marked with #[must_use]. Also, a lot of people were complaining about false positive, but it looks like it has been fixed and is working pretty well now.

After adding #[must_use], there was no additional error, so I guess everything was used

environment,
arguments,
Copy link
Owner

Choose a reason for hiding this comment

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

I wonder whether arguments could be added to the CallingInput? CallingInput already encompasses the sort of hidden arguments that a function call takes, I wonder whether actual values could also be passed here. Or is there a technical reason?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There's a reason I didn't add it, it's because fn call in checker/types/callings takes arguments: &[SynthesisedArgument].
So if we want to add arguments in CallingInput, it'll mean that we need another struct with arguments only for this function. Both are fine I think, do you have a preference?

checker/src/diagnostics.rs Show resolved Hide resolved
checker/src/types/mod.rs Show resolved Hide resolved
parser/src/declarations/mod.rs Outdated Show resolved Hide resolved
parser/src/errors.rs Outdated Show resolved Hide resolved
parser/src/extensions/decorators.rs Show resolved Hide resolved
parser/src/lib.rs Show resolved Hide resolved
src/main.rs Show resolved Hide resolved
@kaleidawave
Copy link
Owner

All changes look good. Just need to fix the something in the WASM section. Then will merge !

@JulesGuesnon
Copy link
Contributor Author

Fixed

@kaleidawave kaleidawave merged commit b5d16a7 into kaleidawave:main Dec 4, 2023
5 of 7 checks passed
@kaleidawave
Copy link
Owner

Awesome, just merged!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
internal-improvements Related to internal publishing, building, workflows, formatting & linting
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants