From ae4bb5d4c1b475e222aa79a136988cc87f9e85fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=96=E5=8D=93=E6=9E=97?= Date: Mon, 3 Aug 2026 08:42:49 +0800 Subject: [PATCH 1/2] Fix missing_docs for implicit actor requirements --- .../Rules/Lint/MissingDocsRule.swift | 14 ++++++++++++++ .../Rules/Lint/MissingDocsRuleExamples.swift | 6 ++++++ 2 files changed, 20 insertions(+) diff --git a/Source/SwiftLintBuiltInRules/Rules/Lint/MissingDocsRule.swift b/Source/SwiftLintBuiltInRules/Rules/Lint/MissingDocsRule.swift index 6a5fb6765f..428d645dd8 100644 --- a/Source/SwiftLintBuiltInRules/Rules/Lint/MissingDocsRule.swift +++ b/Source/SwiftLintBuiltInRules/Rules/Lint/MissingDocsRule.swift @@ -130,6 +130,9 @@ private extension MissingDocsRule { } override func visit(_ node: VariableDeclSyntax) -> SyntaxVisitorContinueKind { + if configuration.excludesInheritedTypes, node.isActorRequirement { + return .skipChildren + } collectViolation(from: node, on: node.bindingSpecifier) return .skipChildren } @@ -152,6 +155,17 @@ private extension MissingDocsRule { } } +private extension VariableDeclSyntax { + var isActorRequirement: Bool { + guard bindings.count == 1, + let identifier = bindings.first?.pattern.as(IdentifierPatternSyntax.self), + identifier.identifier.text == "unownedExecutor" else { + return false + } + return parent?.parent?.parent?.parent?.is(ActorDeclSyntax.self) == true + } +} + private extension DeclGroupSyntax { var inherits: Bool { if let types = inheritanceClause?.inheritedTypes, types.isNotEmpty { diff --git a/Source/SwiftLintBuiltInRules/Rules/Lint/MissingDocsRuleExamples.swift b/Source/SwiftLintBuiltInRules/Rules/Lint/MissingDocsRuleExamples.swift index edef0da32d..0a2b258d67 100644 --- a/Source/SwiftLintBuiltInRules/Rules/Lint/MissingDocsRuleExamples.swift +++ b/Source/SwiftLintBuiltInRules/Rules/Lint/MissingDocsRuleExamples.swift @@ -54,6 +54,12 @@ struct MissingDocsRuleExamples { } """, """ + /// Documentation for MyActor. + public final actor MyActor { + public nonisolated var unownedExecutor: UnownedSerialExecutor { fatalError() } + } + """, + """ /// my doc #if os(macOS) public func f() {} From dffcd706b8e2936af0bb3f0ad8404180e681bd24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=96=E5=8D=93=E6=9E=97?= Date: Mon, 3 Aug 2026 10:17:14 +0800 Subject: [PATCH 2/2] Add changelog entry for missing docs fix --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d74d76a455..c105c4d438 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,6 +28,10 @@ ### Bug Fixes +* Fix `missing_docs` false positives for implicit actor requirements. + [ZHUOLIN0928](https://github.com/ZHUOLIN0928) + [#5422](https://github.com/realm/SwiftLint/issues/5422) + * Add an opt-in `allow_explicit_unsafe_unowned` option to let the `unowned_variable_capture` rule accept explicit `unowned(unsafe)` captures. [Yurii Bakurov](https://github.com/Yurii201811)