Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
14 changes: 14 additions & 0 deletions Source/SwiftLintBuiltInRules/Rules/Lint/MissingDocsRule.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {}
Expand Down