Skip to content

feat: add redundant_final_actor rule#6595

Closed
VDurocher wants to merge 2 commits intorealm:mainfrom
VDurocher:feat/redundant-final-actor-rule
Closed

feat: add redundant_final_actor rule#6595
VDurocher wants to merge 2 commits intorealm:mainfrom
VDurocher:feat/redundant-final-actor-rule

Conversation

@VDurocher
Copy link
Copy Markdown

Description

Adds a new redundant_final_actor rule that warns when a final modifier is applied to an actor declaration.

Per SE-0306, actors are reference types without support for inheritance, so they are implicitly final. Writing final actor is therefore redundant, similar to how internal is redundant as an access modifier.

Closes #6407

Examples

Triggers:

final actor DataStorage {}

final actor Counter {
    var count = 0
}

public final actor Scheduler {}

Does not trigger:

actor DataStorage {}

public actor Scheduler {}

final class Foo {}  // still valid for classes

Auto-correction

This rule supports auto-correction: it removes the redundant final modifier automatically.

Notes

  • BuiltInRules.swift updated manually (run make register to verify the generated output matches)
  • CHANGELOG entry to be added under ### Enhancements in ## Main

Actors are implicitly `final` in Swift (SE-0306); the `final`
modifier is redundant and should be removed.

Closes realm#6407
@SwiftLintBot
Copy link
Copy Markdown

SwiftLintBot commented Apr 12, 2026

15 Warnings
⚠️ This PR may need tests.
⚠️ This PR introduced a violation in DuckDuckGo: /SharedPackages/VPN/Sources/VPN/Diagnostics/NetworkProtectionConnectionBandwidthAnalyzer.swift:26:1: Warning: Actors are implicitly final; the final modifier is redundant. (redundant_final_actor)
⚠️ This PR introduced a violation in DuckDuckGo: /SharedPackages/VPN/Sources/VPN/Diagnostics/KeyExpirationTester.swift:27:1: Warning: Actors are implicitly final; the final modifier is redundant. (redundant_final_actor)
⚠️ This PR introduced a violation in DuckDuckGo: /SharedPackages/BrowserServicesKit/Sources/BrowserServicesKit/Watchdog/Watchdog.swift:26:8: Warning: Actors are implicitly final; the final modifier is redundant. (redundant_final_actor)
⚠️ This PR introduced a violation in DuckDuckGo: /SharedPackages/BrowserServicesKit/Sources/Networking/Auth/OAuthClient.swift:151:1: Warning: Actors are implicitly final; the final modifier is redundant. (redundant_final_actor)
⚠️ This PR introduced a violation in DuckDuckGo: /iOS/DuckDuckGo/AdAttribution/AdAttributionPixelReporter.swift:25:1: Warning: Actors are implicitly final; the final modifier is redundant. (redundant_final_actor)
⚠️ This PR introduced a violation in DuckDuckGo: /iOS/SharedTestUtils/Mocks/Core/Statistics/MockPixelFiring.swift:42:1: Warning: Actors are implicitly final; the final modifier is redundant. (redundant_final_actor)
⚠️ This PR introduced a violation in Swift: /stdlib/public/Concurrency/MainActor.swift:20:21: Warning: Actors are implicitly final; the final modifier is redundant. (redundant_final_actor)
⚠️ This PR introduced a violation in Swift: /stdlib/public/Concurrency/MainActor.swift:42:21: Warning: Actors are implicitly final; the final modifier is redundant. (redundant_final_actor)
⚠️ This PR introduced a violation in Wire: /wire-ios/Wire-iOS/Sources/UserInterface/Conversation/MessagesIndividualUpdatesFactory.swift:23:1: Warning: Actors are implicitly final; the final modifier is redundant. (redundant_final_actor)
⚠️ This PR introduced a violation in Wire: /WireMessaging/Sources/WireMessagingData/WireDrive/WireDriveNodeUploadManager.swift:23:9: Warning: Actors are implicitly final; the final modifier is redundant. (redundant_final_actor)
⚠️ This PR introduced a violation in Wire: /WireMessaging/Sources/WireMessagingData/WireDrive/NodesAPI/NodesAPI.swift:28:9: Warning: Actors are implicitly final; the final modifier is redundant. (redundant_final_actor)
⚠️ This PR introduced a violation in Wire: /wire-ios-data-model/Source/MLS/SubconversationGroupIDRepository.swift:68:8: Warning: Actors are implicitly final; the final modifier is redundant. (redundant_final_actor)
⚠️ This PR introduced a violation in WordPress: /WordPress/Classes/Services/BlockEditorCache.swift:6:1: Warning: Actors are implicitly final; the final modifier is redundant. (redundant_final_actor)
⚠️ This PR introduced a violation in WordPress: /Tests/KeystoneTests/Tests/Utility/ApplicationPasswordsRepositoryTests.swift:599:9: Warning: Actors are implicitly final; the final modifier is redundant. (redundant_final_actor)
19 Messages
📖 Building this branch resulted in a binary size of 27523.01 KiB vs 27495.63 KiB when built on main (0% larger).
📖 Linting Aerial with this PR took 0.8 s vs 0.81 s on main (1% faster).
📖 Linting Alamofire with this PR took 1.06 s vs 1.05 s on main (0% slower).
📖 Linting Brave with this PR took 7.3 s vs 7.18 s on main (1% slower).
📖 Linting DuckDuckGo with this PR took 28.23 s vs 27.87 s on main (1% slower).
📖 Linting Firefox with this PR took 12.24 s vs 12.26 s on main (0% faster).
📖 Linting Kickstarter with this PR took 8.47 s vs 8.47 s on main (0% slower).
📖 Linting Moya with this PR took 0.46 s vs 0.46 s on main (0% slower).
📖 Linting NetNewsWire with this PR took 2.65 s vs 2.68 s on main (1% faster).
📖 Linting Nimble with this PR took 0.7 s vs 0.7 s on main (0% slower).
📖 Linting PocketCasts with this PR took 7.79 s vs 7.79 s on main (0% slower).
📖 Linting Quick with this PR took 0.44 s vs 0.44 s on main (0% slower).
📖 Linting Realm with this PR took 3.07 s vs 3.02 s on main (1% slower).
📖 Linting Sourcery with this PR took 1.88 s vs 1.91 s on main (1% faster).
📖 Linting Swift with this PR took 4.73 s vs 4.75 s on main (0% faster).
📖 Linting SwiftLintPerformanceTests with this PR took 0.31 s vs 0.36 s on main (13% faster).
📖 Linting VLC with this PR took 1.24 s vs 1.25 s on main (0% faster).
📖 Linting Wire with this PR took 19.09 s vs 19.06 s on main (0% slower).
📖 Linting WordPress with this PR took 12.87 s vs 12.87 s on main (0% slower).

Generated by 🚫 Danger

@SimplyDanny
Copy link
Copy Markdown
Collaborator

Thank you! Unfortunately, I have to tell you that there is another PR already that I just haven't found the time to review. I would like to move that one forward.

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.

Rule Request: Redundant final for actors

3 participants