Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
thomasvl opened this issue Sep 24, 2024 · 5 comments

Comments

@thomasvl
Copy link

  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.
@ahoppen
Copy link
Member

ahoppen commented Sep 24, 2024

Synced to Apple’s issue tracker as rdar://136589532

@ahoppen
Copy link
Member

ahoppen commented Oct 14, 2024

Duplicate of #771

@ahoppen ahoppen marked this as a duplicate of #771 Oct 14, 2024
@ahoppen ahoppen closed this as completed Oct 14, 2024
@thomasvl
Copy link
Author

@ahoppen so that duplicate might by why the suppression doesn't work, but the error here is also pretty odd. The variable does not end in "Message" as the message suggests. I have a feeling there is also something else wrong in the check.

@thomasvl
Copy link
Author

Opened #854 to just track the message vs impl and leave off the referenced duplicate.

@ahoppen
Copy link
Member

ahoppen commented Oct 14, 2024

Oh, thanks. I missed the part about the message being incorrect here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants