Skip to content

Rule Request: Orphaned docstrings #2989

Closed

Description

@soffes

At Lyft, we've seen several places where someone adds a disable between a docstring and whatever it's describing like this:

/// My great property
// swiftlint:disable:next force_unwrap
var myGreatProperty: String!

This prevents Xcode from properly rendering the docstring.

I created a very simple rule for this that doesn't catch several things:

orphan_docstring:
  name: For a docstring to work correctly, it must be next to what it is describing.
  regex: '///\w*\n\s*//(?!/)'

Ideally, it would ensure the following line is some value property, type, function, etc. Doing this would also catch /// instead of // for regular comments inside a method body or something.

It would be great if there was a more sophisticated official rule to properly figure out when a docstring is orphaned and warn the user.

Activity

  1. added
    rule-request
    on Jan 5, 2020
  2. added 3 commits that reference this issue on Jan 5, 2020
    de89ae8
    33dde02
    270613a
  3. added a commit that references this issue on Jan 6, 2020
    c2bdb58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    rule-request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions