realm / SwiftLint

A tool to enforce Swift style and conventions.
https://realm.github.io/SwiftLint
MIT License
18.45k stars 2.2k forks source link

missing_docs doesn't trigger for non-inherited properties/functions when using excludes_inherited_types #5633

Open bobbradley opened 2 weeks ago

bobbradley commented 2 weeks ago

New Issue Checklist

Describe the bug

If missing_docs is enabled and excludes_inherited_types is true then undocumented and non-inherited public properties/functions don't trigger missing_docs warnings if the type inherits from a protocol. For example:

/// My type.
public struct MyType: Identifiable {
    public id: String // No warning expected here because this property comes from `Identifiable`.

    // Warning expected here because it's not inherited from `Identifiable`, but warning is not reported.
    public name: String
}
Complete output when running SwiftLint, including the stack trace and command used
$ swiftlint lint
Linting Swift files in current working directory
Linting 'Test.swift' (1/1)
Done linting! Found 0 violations, 0 serious in 1 file.

Environment

opt_in_rules:
  - missing_docs

missing_docs:
  excludes_inherited_types: true
/// My type.
public struct MyType: Identifiable {
    public id: String // No warning expected here because this property comes from `Identifiable`.

    // Warning expected here because it's not inherited from `Identifiable`, but warning is not reported.
    public name: String
}
SimplyDanny commented 5 hours ago

SwiftLint works on the syntax level only. So it doesn't know which declarations exactly stem from a protocol or parent class. This is why excludes_inherited_types exists and, with it enabled, the rule ignores inheriting types completely.