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

Add new redundant_sendable rule #5902

Merged
merged 1 commit into from
Dec 25, 2024

Conversation

SimplyDanny
Copy link
Collaborator

@SwiftLintBot
Copy link

SwiftLintBot commented Dec 20, 2024

4 Warnings
⚠️ This PR introduced a violation in Brave: /Sources/Brave/WebFilters/AdblockResourceDownloader.swift:12:14: warning: Redundant Sendable Violation: Sendable conformance is redundant on an actor-isolated type (redundant_sendable)
⚠️ This PR introduced a violation in Brave: /Sources/Brave/WebFilters/ResourceDownloader.swift:11:7: warning: Redundant Sendable Violation: Sendable conformance is redundant on an actor-isolated type (redundant_sendable)
⚠️ This PR introduced a violation in Brave: /Sources/BraveTalk/BraveTalkJitsiCoordinator.swift:13:25: warning: Redundant Sendable Violation: Sendable conformance is redundant on an actor-isolated type (redundant_sendable)
⚠️ This PR introduced a violation in Realm: /Realm/ObjectServerTests/SwiftUIServerTests.swift:571:7: warning: Redundant Sendable Violation: Sendable conformance is redundant on an actor-isolated type (redundant_sendable)
17 Messages
📖 Linting Aerial with this PR took 0.93s vs 0.95s on main (2% faster)
📖 Linting Alamofire with this PR took 1.27s vs 1.27s on main (0% slower)
📖 Linting Brave with this PR took 7.27s vs 7.28s on main (0% faster)
📖 Linting DuckDuckGo with this PR took 5.46s vs 5.48s on main (0% faster)
📖 Linting Firefox with this PR took 11.0s vs 11.03s on main (0% faster)
📖 Linting Kickstarter with this PR took 10.39s vs 10.29s on main (0% slower)
📖 Linting Moya with this PR took 0.54s vs 0.53s on main (1% slower)
📖 Linting NetNewsWire with this PR took 2.95s vs 2.95s on main (0% slower)
📖 Linting Nimble with this PR took 0.8s vs 0.8s on main (0% slower)
📖 Linting PocketCasts with this PR took 8.73s vs 8.74s on main (0% faster)
📖 Linting Quick with this PR took 0.46s vs 0.47s on main (2% faster)
📖 Linting Realm with this PR took 4.51s vs 4.52s on main (0% faster)
📖 Linting Sourcery with this PR took 2.34s vs 2.33s on main (0% slower)
📖 Linting Swift with this PR took 4.55s vs 4.55s on main (0% slower)
📖 Linting VLC with this PR took 1.27s vs 1.27s on main (0% slower)
📖 Linting Wire with this PR took 18.34s vs 18.29s on main (0% slower)
📖 Linting WordPress with this PR took 11.55s vs 11.58s on main (0% faster)

Generated by 🚫 Danger

@SimplyDanny
Copy link
Collaborator Author

SimplyDanny commented Dec 20, 2024

@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.

Copy link

@mattmassicotte mattmassicotte left a 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 }"),

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"]]),

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?

Copy link
Collaborator Author

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.

@mattmassicotte
Copy link

As for the description, I think you can simplify things a little if you want:

Add new redundant_sendable rule that triggers on Sendable conformances of types that are implicitly already Sendable due to being actor-isolated.

@SimplyDanny
Copy link
Collaborator Author

At the moment, this rule needs to be enabled explicitly. Feels like it's clear and safe enough to enable it by default though.

@SimplyDanny SimplyDanny merged commit 03f8c83 into realm:main Dec 25, 2024
12 checks passed
@SimplyDanny SimplyDanny deleted the redundant-sendable branch December 25, 2024 22:05
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.

3 participants