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

adds new trait-method-added lint #891

Merged
merged 2 commits into from
Aug 29, 2024

Conversation

PedroTurik
Copy link
Contributor

see #870

@PedroTurik PedroTurik marked this pull request as ready for review August 28, 2024 20:05
Copy link
Owner

@obi1kenobi obi1kenobi left a comment

Choose a reason for hiding this comment

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

A couple of minor comments, otherwise looks good!

item {
... on Trait {
visibility_limit @filter(op: "=", value: ["$public"]) @output
sealed @filter(op: "!=", value: ["$true"])
Copy link
Owner

Choose a reason for hiding this comment

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

This one's tricky, and could have gone either way. So far, we've been treating "the trait got sealed" and "new items requiring implementation got added" as separate issues which should both lint. That's how the other lints in this category work too.

For consistency, we should remove this.

Suggested change
sealed @filter(op: "!=", value: ["$true"])

Would you mind adding a test case that covers this as well?

Comment on lines 25 to 29
/*
Will let this case to be reported only by the newly sealed trait Lint,
and not by this one, since sealing a trait indicates that the user
wants to remove this type from the public API.
*/
Copy link
Owner

Choose a reason for hiding this comment

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

This is correct, and like I said earlier, it's a judgment call that could go either way.

The opposite argument is that the user might not have realized that their trait is sealed (it has become so by accident). In that case, since it wasn't an intentional decision, items requiring implementation are a separate and unrelated issue.

Comment on lines +23 to +31
method {
method_name: name @output @tag
has_body @filter(op: "!=", value: ["$true"])

span_: span @optional {
filename @output
begin_line @output
}
}
Copy link
Owner

Choose a reason for hiding this comment

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

This portion is correctly implemented, but would be lovely if we had a test case for one more situation that users might find confusing.

Users might think that marking the new method #[doc(hidden)] may resolve this lint. It shouldn't, and it'd be great to have a test for it.

For bonus points, if you're interested, you could take a look at our other "trait item added without default" lints and make sure they all have a "#[doc(hidden)] on the new item" test case as well. If not, more PRs are welcome!

@obi1kenobi
Copy link
Owner

If you're open to adding tests for #[doc(hidden)] added methods, I'd love to merge those too! This code looks good so I'm merging it as well 🚀

@obi1kenobi obi1kenobi merged commit 9900692 into obi1kenobi:main Aug 29, 2024
33 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