-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Add new redundant_sendable
rule
#5902
Conversation
Generated by 🚫 Danger |
@mattmassicotte: I'd appreciate your opinion on the test cases/examples and the rule's description (which is also the message shown for a violation). Admittedly, I'm not super happy with the wording. |
59dd9c1
to
c91baed
Compare
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 looks like a super-cool addition! And it's already catching (likely) real mistakes in projects today so well done!
Example("class C: Sendable {}"), | ||
Example("actor A {}"), | ||
Example("@MainActor struct S {}"), | ||
Example("@MyActor enum E: Sendable { case a }"), |
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.
Why should this last one not trigger?
triggeringExamples: [ | ||
Example("@MainActor struct ↓S: Sendable {}"), | ||
Example("actor ↓A: Sendable {}"), | ||
Example("@MyActor enum ↓E: Sendable { case a }", configuration: ["global_actors": ["MyActor"]]), |
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.
Oh I think I get it, the actor has to be defined first?
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.
Since the rule only operates on syntax-level, it needs to have global actors defined by name. There's no other way to know if the attribute is an actor or something else. @MainActor
is clear and perhaps also @...Actor
but that's too vague. Global actors aren't something that changes often, so people can just add their names to the configuration. It's always a trade-off.
As for the description, I think you can simplify things a little if you want:
|
At the moment, this rule needs to be enabled explicitly. Feels like it's clear and safe enough to enable it by default though. |
c91baed
to
7992cdf
Compare
7992cdf
to
587a922
Compare
Inspired by https://www.massicotte.org/step-by-step-reading-from-storage.