SwiftLint icon indicating copy to clipboard operation
SwiftLint copied to clipboard

missing_docs warns about actors not documenting public protocol properties

Open bobbradley opened this issue 1 year ago • 7 comments

New Issue Checklist

Describe the bug

If you use the "actor" keyword, it implicitly conforms to the "Actor" protocol, but SwiftLint still warns about not documenting public properties from the Actor protocol. For example, if you provide a public "unownedExecutor", it warns about it not documenting it. But if you explicitly conform to "Actor" then it doesn't warn.

It seems like SwiftLint should treat actors as if they explicitly specified they conform to the "Actor" protocol.

Generates warnings

/// Documentation for MyActor.
public final actor MyActor {
    public nonisolated var unownedExecutor: UnownedSerialExecutor { ... } // Warns here
}

No warnings

/// Documentation for MyActor.
public final actor MyActor: Actor {
    public nonisolated var unownedExecutor: UnownedSerialExecutor { ... }
}
Complete output when running SwiftLint, including the stack trace and command used
$ swiftlint lint

Environment

  • SwiftLint version (run swiftlint version to be sure)? 0.53.0
  • Installation method used (Homebrew, CocoaPods, building from source, etc)? homebrew
  • Paste your configuration file:
opt_in_rules:
  - missing_docs
  • Are you using nested configurations? No

  • Which Xcode version are you using (check xcodebuild -version)? Invoking SwiftLint directly.

  • Do you have a sample that shows the issue? Pasted above.

bobbradley avatar Jan 16 '24 17:01 bobbradley

The reason you don't get a warning in the second case (explicitly conforming to Actor) might be the option excludes_inherited_types which is true by default.

However, I agree that the rule could know about the protocol methods an actor type comes with by default so it doesn't trigger on them.

SimplyDanny avatar Jan 16 '24 18:01 SimplyDanny

Hi, Can I work on this?🙂

marunomi avatar Feb 05 '24 00:02 marunomi

Hi, Can I work on this?🙂

Sure. Please go ahead.

SimplyDanny avatar Feb 05 '24 10:02 SimplyDanny

I tried to fix this. But as I saw some merged pull requests that rewriting to use Swift Syntax, would I better to change whole file to Swift Syntax use?

marunomi avatar Feb 16 '24 14:02 marunomi

I tried to fix this. But as I saw some merged pull requests that rewriting to use Swift Syntax, would I better to change whole file to Swift Syntax use?

There is a rewrite in #5048 already, but we haven't found the time to review it. It would indeed make sense to wait for it, before this change gets added.

SimplyDanny avatar Feb 17 '24 19:02 SimplyDanny

There is a rewrite in #5048 already, but we haven't found the time to review it. It would indeed make sense to wait for it, before this change gets added.

OK 👍🏻 I got it.

marunomi avatar Feb 19 '24 04:02 marunomi

@marunomi: The PR that rewrites this rule with SwiftSyntax just got merged. It ought to be a bit easier now to implement your enhancement. So please go ahead by rebasing your PR or start over with a new one if you like.

SimplyDanny avatar Jul 02 '24 18:07 SimplyDanny