-
-
Notifications
You must be signed in to change notification settings - Fork 78
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
feat: Add lint for missing trait methods #427
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an excellent start!
The query is almost there, and as I think I mentioned, most of the work is going to be in coming up with good wording for the user-facing error messages and in making good test cases :)
src/lints/trait_method_missing.ron
Outdated
} | ||
|
||
method { | ||
method_visibility: visibility_limit @filter(op: "=", value: ["$public"]) @output |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line is not necessary, since trait methods are always public and cannot have restricted visibility of any form.
method_visibility: visibility_limit @filter(op: "=", value: ["$public"]) @output |
src/lints/trait_method_missing.ron
Outdated
} | ||
} | ||
} | ||
current @fold @transform(op: "count") @filter(op: "=", value: ["$zero"]) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Recall that we're aiming for only a single lint to be triggered for any given semver violation.
With this @fold @transform(op: "count") @filter(op: "=", value: ["$zero"])
here, I believe it's possible to trigger this lint in a case that doesn't involve removing or renaming a trait method.
Can you think of any such example situations? They'd be great to include in the test suite even after updating the query here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ack
src/lints/trait_method_missing.ron
Outdated
"public": "public", | ||
"zero": 0, | ||
}, | ||
error_message: "A publicly-visible trait method is no longer visible, or cannot be called by its prior path. A member, method, or item of the trait may have been renamed or removed entirely.", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's aim to make this message shorter and easier to read. Right now it's a bit confusing since it references ideas that are not obviously related to this lint.
For example, this lint only looks for methods that can't be found, so we don't need to mention other kinds of items that the trait might contain. Also, since visibility restrictions cannot be applied to trait methods (they are all always pub
), "no longer visible" is confusing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ack, still working on it
src/lints/trait_method_missing.ron
Outdated
"zero": 0, | ||
}, | ||
error_message: "A publicly-visible trait method is no longer visible, or cannot be called by its prior path. A member, method, or item of the trait may have been renamed or removed entirely.", | ||
per_result_error_template: Some("trait {{join \"::\" path}}, previously in file {{span_filename}}:{{span_begin_line}}"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's name the problematic method here as well as its trait. Right now we only name the trait, so if more than one method gets removed from the same trait, the user would see a duplicate error message and be quite confused.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ack
I'm still trying to setup the crate so it can build but it seems that there are conflicting types coming from the fact that multiple
What's the best way to update all dependencies on trustfall code? |
It just needed a matching version update for the |
Just checking, are you still interested in pushing this PR forward? No worries if not. |
Thanks for following up. I'd like to see this through but I unfortunately won't have bandwidth this coming week. I'm happy to let someone else takeover the task if there is interest. |
There's no rush, so if you think you'll be able to come back to it in the coming weeks, you're welcome to do that. But also no pressure, it's not a big deal to close this and let someone else take a crack at it. |
src/lints/trait_method_missing.ron
Outdated
filename @output | ||
begin_line @output | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
filename @output | |
begin_line @output | |
} | |
filename @output | |
begin_line @output | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just wanted to help with a quick fix. You're headed in the right direction in general.
Updated the PR with the feedback. It is now ready for review. Thanks @obi1kenobi for all your guidance here. edit: I am seeing some CI failures that I'm not sure how to fix given that I have updated the test outputs. |
As soon as #455 merges, this should start passing tests. Thanks for putting it together! |
- Added a new SemverQuery lint for missing trait methods in `src/lints/trait_method_missing.ron`
- Update and simplify the error message template for the SemverQuery - Add a new trait and remove an old trait in the trait_method_missing test crates
Thanks for putting this together! The nightly failure is on me, we just need to pull in the adapter for the new format and I'll take care of it a bit later. |
trustfall_rustdoc
version to0.10.0
Closes #368