Skip to content

False reports and/or // swift-format-ignore: DontRepeatTypeInStaticProperties doesn't work. #816

@thomasvl

Description

@thomasvl
  1. Checkout https://github.com/apple/swift-protobuf @ c9fbc332ed293c64ff70af8d82367ca530dce11c

  2. swift format lint Sources/SwiftProtobuf/Message.swift - Will produce a warning:

    Sources/SwiftProtobuf/Message.swift:46:16: warning: [DontRepeatTypeInStaticProperties] remove the suffix 'Message' from the name of the variable 'protoMessageName'

  3. Apply this diff:

    diff --git a/Sources/SwiftProtobuf/Message.swift b/Sources/SwiftProtobuf/Message.swift
    index 4d59ab93..8ebbb1e5 100644
    --- a/Sources/SwiftProtobuf/Message.swift
    +++ b/Sources/SwiftProtobuf/Message.swift
    @@ -43,6 +43,7 @@ public protocol Message: Sendable, CustomDebugStringConvertible {
     
         /// The fully-scoped name of the message from the original .proto file,
         /// including any relevant package name.
    +    // swift-format-ignore: DontRepeatTypeInStaticProperties
         static var protoMessageName: String { get }
     
         /// True if all required fields (if any) on this message and any nested
  4. swift format lint Sources/SwiftProtobuf/Message.swift - will still produce the warning (just with the line number increased correctly)

    Sources/SwiftProtobuf/Message.swift:47:16: warning: [DontRepeatTypeInStaticProperties] remove the suffix 'Message' from the name of the variable 'protoMessageName'

Likely issues:

  • I'm not sure the warning is correct since "Message" isn't the suffix, it's actually Name or MessageName
  • The comment to suppress doesn't suppress.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions