SwiftLint icon indicating copy to clipboard operation
SwiftLint copied to clipboard

Add new `attribute_name_spacing` rule

Open aryamansharda opened this issue 1 year ago • 8 comments

Resolves https://github.com/realm/SwiftLint/issues/5667

Seeing as private (set) would cause issues with the Swift 6 compiler in Xcode 16+, this PR implements the changes discussed in the issue linked above.

The rule is now a default rule and prevents the following code from triggering errors:

Triggers: private (set) var type: ClipType = .undetermined

Doesn't Trigger: private(set) var type: ClipType = .undetermined

First time contributing to SwiftLint, so apologies for any contribution mistakes on my end. You managed to convince me to try and contribute @SimplyDanny (re. SwiftCraft)

aryamansharda avatar Jul 13 '24 08:07 aryamansharda

89 Warnings
:warning: This PR introduced a violation in Aerial: /Aerial/Source/Models/API/Forecast.swift:161:44: error: Attribute Name Spacing Violation: @escaping must have a trailing space before the associated type (attribute_name_spacing)
:warning: This PR introduced a violation in Aerial: /Aerial/Source/Models/API/GeoCoding.swift:30:44: error: Attribute Name Spacing Violation: @escaping must have a trailing space before the associated type (attribute_name_spacing)
:warning: This PR introduced a violation in Aerial: /Aerial/Source/Models/API/OneCall.swift:193:44: error: Attribute Name Spacing Violation: @escaping must have a trailing space before the associated type (attribute_name_spacing)
:warning: This PR introduced a violation in Aerial: /Aerial/Source/Models/API/OpenWeather.swift:155:44: error: Attribute Name Spacing Violation: @escaping must have a trailing space before the associated type (attribute_name_spacing)
:warning: This PR introduced a violation in DuckDuckGo: /Core/SyncErrorHandler.swift:42:13: error: Attribute Name Spacing Violation: There must not be any space between access control modifier and scope (attribute_name_spacing)
:warning: This PR introduced a violation in DuckDuckGo: /Core/SyncErrorHandler.swift:49:13: error: Attribute Name Spacing Violation: There must not be any space between access control modifier and scope (attribute_name_spacing)
:warning: This PR introduced a violation in DuckDuckGo: /Core/SyncErrorHandler.swift:56:13: error: Attribute Name Spacing Violation: There must not be any space between access control modifier and scope (attribute_name_spacing)
:warning: This PR introduced a violation in DuckDuckGo: /DuckDuckGo/AutofillLoginListViewModel.swift:121:24: error: Attribute Name Spacing Violation: There must not be any space between access control modifier and scope (attribute_name_spacing)
:warning: This PR introduced a violation in DuckDuckGo: /DuckDuckGo/AutofillLoginListViewModel.swift:227:44: error: Attribute Name Spacing Violation: @escaping must have a trailing space before the associated type (attribute_name_spacing)
:warning: This PR introduced a violation in DuckDuckGo: /DuckDuckGo/ImportPasswordsViewModel.swift:82:13: error: Attribute Name Spacing Violation: There must not be any space between access control modifier and scope (attribute_name_spacing)
:warning: This PR introduced a violation in DuckDuckGo: /DuckDuckGo/SpeechRecognizer.swift:104:50: error: Attribute Name Spacing Violation: @escaping must have a trailing space before the associated type (attribute_name_spacing)
:warning: This PR introduced a violation in DuckDuckGo: /DuckDuckGo/TabViewControllerBrowsingMenuExtension.swift:375:70: error: Attribute Name Spacing Violation: @escaping must have a trailing space before the associated type (attribute_name_spacing)
:warning: This PR introduced a violation in Firefox: /firefox-ios/Storage/Rust/RustPlaces.swift:111:30: error: Attribute Name Spacing Violation: @escaping must have a trailing space before the associated type (attribute_name_spacing)
:warning: This PR introduced a violation in Firefox: /firefox-ios/Storage/Rust/RustPlaces.swift:141:30: error: Attribute Name Spacing Violation: @escaping must have a trailing space before the associated type (attribute_name_spacing)
:warning: This PR introduced a violation in Firefox: /firefox-ios/firefox-ios-tests/Tests/ClientTests/Wallpaper/Mocks/WallpaperURLSessionMock.swift:10:13: error: Attribute Name Spacing Violation: There must not be any space between access control modifier and scope (attribute_name_spacing)
:warning: This PR introduced a violation in PocketCasts: /podcasts/Common SwiftUI/List View/MultiSelectListViewModel.swift:21:13: error: Attribute Name Spacing Violation: There must not be any space between access control modifier and scope (attribute_name_spacing)
:warning: This PR introduced a violation in PocketCasts: /podcasts/IAPHelper.swift:27:13: error: Attribute Name Spacing Violation: There must not be any space between access control modifier and scope (attribute_name_spacing)
:warning: This PR introduced a violation in VLC: /Sources/Cloud/Services/Google Drive/GoogleSignInAuthenticator.swift:15:7: error: Attribute Name Spacing Violation: Attribute declarations with arguments must not have trailing trivia (attribute_name_spacing)
:warning: This PR introduced a violation in VLC: /Sources/Playback/Player/AudioPlayer/AudioPlayerViewController.swift:14:7: error: Attribute Name Spacing Violation: Attribute declarations with arguments must not have trailing trivia (attribute_name_spacing)
:warning: This PR introduced a violation in VLC: /Sources/Playback/Player/AudioPlayer/AudioPlayerViewController.swift:22:7: error: Attribute Name Spacing Violation: Attribute declarations with arguments must not have trailing trivia (attribute_name_spacing)
:warning: This PR introduced a violation in VLC: /Sources/Playback/Player/VideoPlayer-iOS/AspectRatio.swift:14:7: error: Attribute Name Spacing Violation: Attribute declarations with arguments must not have trailing trivia (attribute_name_spacing)
:warning: This PR introduced a violation in VLC: /Sources/Playback/Player/VideoPlayer-iOS/AspectRatio.swift:63:7: error: Attribute Name Spacing Violation: Attribute declarations with arguments must not have trailing trivia (attribute_name_spacing)
:warning: This PR introduced a violation in VLC: /Sources/Playback/Player/VideoPlayer-iOS/MediaMoreOptionsActionSheet.swift:14:7: error: Attribute Name Spacing Violation: Attribute declarations with arguments must not have trailing trivia (attribute_name_spacing)
:warning: This PR introduced a violation in VLC: /Sources/Playback/Player/VideoPlayer-iOS/MediaMoreOptionsActionSheet.swift:40:7: error: Attribute Name Spacing Violation: Attribute declarations with arguments must not have trailing trivia (attribute_name_spacing)
:warning: This PR introduced a violation in VLC: /Sources/Playback/Player/VideoPlayer-iOS/MediaScrubProgressBar.swift:13:7: error: Attribute Name Spacing Violation: Attribute declarations with arguments must not have trailing trivia (attribute_name_spacing)
:warning: This PR introduced a violation in VLC: /Sources/Playback/Player/VideoPlayer-iOS/MediaScrubProgressBar.swift:21:7: error: Attribute Name Spacing Violation: Attribute declarations with arguments must not have trailing trivia (attribute_name_spacing)
:warning: This PR introduced a violation in VLC: /Sources/Playback/Player/VideoPlayer-iOS/Subviews/MediaNavigationBar.swift:16:7: error: Attribute Name Spacing Violation: Attribute declarations with arguments must not have trailing trivia (attribute_name_spacing)
:warning: This PR introduced a violation in VLC: /Sources/Playback/Player/VideoPlayer-iOS/Subviews/MediaNavigationBar.swift:29:7: error: Attribute Name Spacing Violation: Attribute declarations with arguments must not have trailing trivia (attribute_name_spacing)
:warning: This PR introduced a violation in VLC: /Sources/Playback/Player/VideoPlayer-iOS/Subviews/MediaPlayerActionSheet.swift:88:7: error: Attribute Name Spacing Violation: Attribute declarations with arguments must not have trailing trivia (attribute_name_spacing)
:warning: This PR introduced a violation in VLC: /Sources/Playback/Player/VideoPlayer-iOS/Subviews/MediaPlayerActionSheet.swift:93:7: error: Attribute Name Spacing Violation: Attribute declarations with arguments must not have trailing trivia (attribute_name_spacing)
:warning: This PR introduced a violation in VLC: /Sources/Playback/Player/VideoPlayer-iOS/Subviews/MediaPlayerActionSheet.swift:99:7: error: Attribute Name Spacing Violation: Attribute declarations with arguments must not have trailing trivia (attribute_name_spacing)
:warning: This PR introduced a violation in VLC: /Sources/Playback/Player/VideoPlayer-iOS/VideoPlayerControls.swift:13:7: error: Attribute Name Spacing Violation: Attribute declarations with arguments must not have trailing trivia (attribute_name_spacing)
:warning: This PR introduced a violation in VLC: /Sources/UI Elements/ActionSheet/ActionSheetCell.swift:39:7: error: Attribute Name Spacing Violation: Attribute declarations with arguments must not have trailing trivia (attribute_name_spacing)
:warning: This PR introduced a violation in VLC: /Sources/UI Elements/ActionSheet/ActionSheetCell.swift:61:7: error: Attribute Name Spacing Violation: Attribute declarations with arguments must not have trailing trivia (attribute_name_spacing)
:warning: This PR introduced a violation in VLC: /Sources/UI Elements/ActionSheet/ActionSheetCell.swift:67:7: error: Attribute Name Spacing Violation: Attribute declarations with arguments must not have trailing trivia (attribute_name_spacing)
:warning: This PR introduced a violation in Wire: /wire-ios-data-model/Source/Model/Conversation/AssetCollection.swift:59:20: error: Attribute Name Spacing Violation: There must not be any space between access control modifier and scope (attribute_name_spacing)
:warning: This PR introduced a violation in Wire: /wire-ios-data-model/Source/Model/Conversation/AssetCollection.swift:60:20: error: Attribute Name Spacing Violation: There must not be any space between access control modifier and scope (attribute_name_spacing)
:warning: This PR introduced a violation in Wire: /wire-ios-data-model/Source/Model/Message/LocationData.swift:21:7: error: Attribute Name Spacing Violation: Attribute declarations with arguments must not have trailing trivia (attribute_name_spacing)
:warning: This PR introduced a violation in Wire: /wire-ios-data-model/Source/Notifications/SearchUserObserverCenter.swift:51:20: error: Attribute Name Spacing Violation: There must not be any space between access control modifier and scope (attribute_name_spacing)
:warning: This PR introduced a violation in Wire: /wire-ios-sync-engine/Source/Data Model/Conversation+TypingUsers.swift:23:11: error: Attribute Name Spacing Violation: Attribute declarations with arguments must not have trailing trivia (attribute_name_spacing)
:warning: This PR introduced a violation in Wire: /wire-ios-sync-engine/Source/Data Model/TypingUsers.swift:29:11: error: Attribute Name Spacing Violation: Attribute declarations with arguments must not have trailing trivia (attribute_name_spacing)
:warning: This PR introduced a violation in Wire: /wire-ios-sync-engine/Source/Synchronization/Strategies/ConversationRoleDownstreamRequestStrategy.swift:47:13: error: Attribute Name Spacing Violation: There must not be any space between access control modifier and scope (attribute_name_spacing)
:warning: This PR introduced a violation in Wire: /wire-ios-sync-engine/Source/Synchronization/Strategies/ProxiedRequestStrategy.swift:48:16: error: Attribute Name Spacing Violation: Attribute declarations with arguments must not have trailing trivia (attribute_name_spacing)
:warning: This PR introduced a violation in Wire: /wire-ios-sync-engine/Source/Synchronization/Strategies/SearchUserImageStrategy.swift:39:16: error: Attribute Name Spacing Violation: Attribute declarations with arguments must not have trailing trivia (attribute_name_spacing)
:warning: This PR introduced a violation in Wire: /wire-ios-sync-engine/Source/Synchronization/Strategies/TeamDownloadRequestStrategy.swift:91:13: error: Attribute Name Spacing Violation: There must not be any space between access control modifier and scope (attribute_name_spacing)
:warning: This PR introduced a violation in Wire: /wire-ios-sync-engine/Source/Synchronization/Strategies/TeamDownloadRequestStrategy.swift:92:13: error: Attribute Name Spacing Violation: There must not be any space between access control modifier and scope (attribute_name_spacing)
:warning: This PR introduced a violation in Wire: /wire-ios-sync-engine/Source/Synchronization/Strategies/TypingStrategy.swift:115:16: error: Attribute Name Spacing Violation: Attribute declarations with arguments must not have trailing trivia (attribute_name_spacing)
:warning: This PR introduced a violation in Wire: /wire-ios-sync-engine/Source/Synchronization/Strategies/UserProfileUpdateRequestStrategy.swift:35:16: error: Attribute Name Spacing Violation: Attribute declarations with arguments must not have trailing trivia (attribute_name_spacing)
:warning: This PR introduced a violation in Wire: /wire-ios-sync-engine/Source/UserSession/SyncStatus.swift:34:21: error: Attribute Name Spacing Violation: There must not be any space between access control modifier and scope (attribute_name_spacing)
:warning: This PR introduced a violation in Wire: /wire-ios-sync-engine/Source/UserSession/SyncStatus.swift:51:21: error: Attribute Name Spacing Violation: There must not be any space between access control modifier and scope (attribute_name_spacing)
:warning: This PR introduced a violation in Wire: /wire-ios-sync-engine/Source/UserSession/SyncStatus.swift:52:21: error: Attribute Name Spacing Violation: There must not be any space between access control modifier and scope (attribute_name_spacing)
:warning: This PR introduced a violation in Wire: /wire-ios-sync-engine/Source/UserSession/SyncStatus.swift:53:21: error: Attribute Name Spacing Violation: There must not be any space between access control modifier and scope (attribute_name_spacing)
:warning: This PR introduced a violation in Wire: /wire-ios-sync-engine/Source/UserSession/SyncStatus.swift:54:21: error: Attribute Name Spacing Violation: There must not be any space between access control modifier and scope (attribute_name_spacing)
:warning: This PR introduced a violation in Wire: /wire-ios/Tests/Mocks/MockConversation+factory.swift:72:11: error: Attribute Name Spacing Violation: Attribute declarations with arguments must not have trailing trivia (attribute_name_spacing)
:warning: This PR introduced a violation in Wire: /wire-ios/Tests/Mocks/MockConversation+factory.swift:77:11: error: Attribute Name Spacing Violation: Attribute declarations with arguments must not have trailing trivia (attribute_name_spacing)
:warning: This PR introduced a violation in Wire: /wire-ios/Wire-iOS/Sources/UserInterface/UserProfile/Devices/ProfileClientViewModel.swift:25:13: error: Attribute Name Spacing Violation: There must not be any space between access control modifier and scope (attribute_name_spacing)
:warning: This PR introduced a violation in WordPress: /WordPress/Classes/Models/Page.swift:4:7: error: Attribute Name Spacing Violation: Attribute declarations with arguments must not have trailing trivia (attribute_name_spacing)
:warning: This PR introduced a violation in WordPress: /WordPress/Classes/Services/JetpackScanService.swift:102:131: error: Attribute Name Spacing Violation: @escaping must have a trailing space before the associated type (attribute_name_spacing)
:warning: This PR introduced a violation in WordPress: /WordPress/Classes/Services/JetpackScanService.swift:102:79: error: Attribute Name Spacing Violation: @escaping must have a trailing space before the associated type (attribute_name_spacing)
:warning: This PR introduced a violation in WordPress: /WordPress/Classes/Services/JetpackScanService.swift:111:102: error: Attribute Name Spacing Violation: @escaping must have a trailing space before the associated type (attribute_name_spacing)
:warning: This PR introduced a violation in WordPress: /WordPress/Classes/Services/JetpackScanService.swift:111:156: error: Attribute Name Spacing Violation: @escaping must have a trailing space before the associated type (attribute_name_spacing)
:warning: This PR introduced a violation in WordPress: /WordPress/Classes/Services/JetpackScanService.swift:120:112: error: Attribute Name Spacing Violation: @escaping must have a trailing space before the associated type (attribute_name_spacing)
:warning: This PR introduced a violation in WordPress: /WordPress/Classes/Services/JetpackScanService.swift:120:82: error: Attribute Name Spacing Violation: @escaping must have a trailing space before the associated type (attribute_name_spacing)
:warning: This PR introduced a violation in WordPress: /WordPress/Classes/Services/JetpackScanService.swift:12:101: error: Attribute Name Spacing Violation: @escaping must have a trailing space before the associated type (attribute_name_spacing)
:warning: This PR introduced a violation in WordPress: /WordPress/Classes/Services/JetpackScanService.swift:12:67: error: Attribute Name Spacing Violation: @escaping must have a trailing space before the associated type (attribute_name_spacing)
:warning: This PR introduced a violation in WordPress: /WordPress/Classes/Services/JetpackScanService.swift:130:103: error: Attribute Name Spacing Violation: @escaping must have a trailing space before the associated type (attribute_name_spacing)
:warning: This PR introduced a violation in WordPress: /WordPress/Classes/Services/JetpackScanService.swift:130:55: error: Attribute Name Spacing Violation: @escaping must have a trailing space before the associated type (attribute_name_spacing)
:warning: This PR introduced a violation in WordPress: /WordPress/Classes/Services/JetpackScanService.swift:21:52: error: Attribute Name Spacing Violation: @escaping must have a trailing space before the associated type (attribute_name_spacing)
:warning: This PR introduced a violation in WordPress: /WordPress/Classes/Services/JetpackScanService.swift:21:93: error: Attribute Name Spacing Violation: @escaping must have a trailing space before the associated type (attribute_name_spacing)
:warning: This PR introduced a violation in WordPress: /WordPress/Classes/Services/JetpackScanService.swift:30:117: error: Attribute Name Spacing Violation: @escaping must have a trailing space before the associated type (attribute_name_spacing)
:warning: This PR introduced a violation in WordPress: /WordPress/Classes/Services/JetpackScanService.swift:30:76: error: Attribute Name Spacing Violation: @escaping must have a trailing space before the associated type (attribute_name_spacing)
:warning: This PR introduced a violation in WordPress: /WordPress/Classes/Services/JetpackScanService.swift:83:54: error: Attribute Name Spacing Violation: @escaping must have a trailing space before the associated type (attribute_name_spacing)
:warning: This PR introduced a violation in WordPress: /WordPress/Classes/Services/JetpackScanService.swift:83:88: error: Attribute Name Spacing Violation: @escaping must have a trailing space before the associated type (attribute_name_spacing)
:warning: This PR introduced a violation in WordPress: /WordPress/Classes/Services/JetpackScanService.swift:93:137: error: Attribute Name Spacing Violation: @escaping must have a trailing space before the associated type (attribute_name_spacing)
:warning: This PR introduced a violation in WordPress: /WordPress/Classes/Services/JetpackScanService.swift:93:83: error: Attribute Name Spacing Violation: @escaping must have a trailing space before the associated type (attribute_name_spacing)
:warning: This PR introduced a violation in WordPress: /WordPress/Classes/Services/QRLoginService.swift:12:113: error: Attribute Name Spacing Violation: @escaping must have a trailing space before the associated type (attribute_name_spacing)
:warning: This PR introduced a violation in WordPress: /WordPress/Classes/Services/QRLoginService.swift:12:58: error: Attribute Name Spacing Violation: @escaping must have a trailing space before the associated type (attribute_name_spacing)
:warning: This PR introduced a violation in WordPress: /WordPress/Classes/Services/QRLoginService.swift:16:62: error: Attribute Name Spacing Violation: @escaping must have a trailing space before the associated type (attribute_name_spacing)
:warning: This PR introduced a violation in WordPress: /WordPress/Classes/Services/QRLoginService.swift:16:96: error: Attribute Name Spacing Violation: @escaping must have a trailing space before the associated type (attribute_name_spacing)
:warning: This PR introduced a violation in WordPress: /WordPress/Classes/Utility/Blogging Prompts/PromptRemindersScheduler.swift:146:100: error: Attribute Name Spacing Violation: @escaping must have a trailing space before the associated type (attribute_name_spacing)
:warning: This PR introduced a violation in WordPress: /WordPress/Classes/Utility/Media/MediaFileManager.swift:46:11: error: Attribute Name Spacing Violation: Attribute declarations with arguments must not have trailing trivia (attribute_name_spacing)
:warning: This PR introduced a violation in WordPress: /WordPress/Classes/Utility/Media/MediaFileManager.swift:53:11: error: Attribute Name Spacing Violation: Attribute declarations with arguments must not have trailing trivia (attribute_name_spacing)
:warning: This PR introduced a violation in WordPress: /WordPress/Classes/ViewRelated/Post/Revisions/Browser/RevisionBrowserState.swift:10:13: error: Attribute Name Spacing Violation: There must not be any space between access control modifier and scope (attribute_name_spacing)
:warning: This PR introduced a violation in WordPress: /WordPress/Classes/ViewRelated/Post/Revisions/Browser/RevisionBrowserState.swift:9:13: error: Attribute Name Spacing Violation: There must not be any space between access control modifier and scope (attribute_name_spacing)
:warning: This PR introduced a violation in WordPress: /WordPress/Classes/ViewRelated/Post/Revisions/Views/Operation/RevisionOperation.swift:4:23: error: Attribute Name Spacing Violation: There must not be any space between access control modifier and scope (attribute_name_spacing)
:warning: This PR introduced a violation in WordPress: /WordPress/WordPressTest/QRLogin/QRLoginVerifyCoordinatorTests.swift:382:122: error: Attribute Name Spacing Violation: @escaping must have a trailing space before the associated type (attribute_name_spacing)
:warning: This PR introduced a violation in WordPress: /WordPress/WordPressTest/QRLogin/QRLoginVerifyCoordinatorTests.swift:382:67: error: Attribute Name Spacing Violation: @escaping must have a trailing space before the associated type (attribute_name_spacing)
:warning: This PR introduced a violation in WordPress: /WordPress/WordPressTest/QRLogin/QRLoginVerifyCoordinatorTests.swift:400:105: error: Attribute Name Spacing Violation: @escaping must have a trailing space before the associated type (attribute_name_spacing)
:warning: This PR introduced a violation in WordPress: /WordPress/WordPressTest/QRLogin/QRLoginVerifyCoordinatorTests.swift:400:71: error: Attribute Name Spacing Violation: @escaping must have a trailing space before the associated type (attribute_name_spacing)
17 Messages
:book: Linting Aerial with this PR took 0.91s vs 0.92s on main (1% faster)
:book: Linting Alamofire with this PR took 1.27s vs 1.26s on main (0% slower)
:book: Linting Brave with this PR took 7.43s vs 7.39s on main (0% slower)
:book: Linting DuckDuckGo with this PR took 4.86s vs 4.87s on main (0% faster)
:book: Linting Firefox with this PR took 10.95s vs 10.93s on main (0% slower)
:book: Linting Kickstarter with this PR took 9.99s vs 9.96s on main (0% slower)
:book: Linting Moya with this PR took 0.53s vs 0.53s on main (0% slower)
:book: Linting NetNewsWire with this PR took 2.54s vs 2.54s on main (0% slower)
:book: Linting Nimble with this PR took 0.77s vs 0.76s on main (1% slower)
:book: Linting PocketCasts with this PR took 8.57s vs 8.53s on main (0% slower)
:book: Linting Quick with this PR took 0.45s vs 0.43s on main (4% slower)
:book: Linting Realm with this PR took 4.65s vs 4.64s on main (0% slower)
:book: Linting Sourcery with this PR took 2.33s vs 2.35s on main (0% faster)
:book: Linting Swift with this PR took 4.55s vs 4.55s on main (0% slower)
:book: Linting VLC with this PR took 1.24s vs 1.25s on main (0% faster)
:book: Linting Wire with this PR took 18.15s vs 18.1s on main (0% slower)
:book: Linting WordPress with this PR took 11.73s vs 11.76s on main (0% faster)

Generated by :no_entry_sign: Danger

SwiftLintBot avatar Jul 13 '24 08:07 SwiftLintBot

Hey @aryamansharda, nice to hear from you and even better via a contribution!

The implementation looks good to me. Yet, checking the commits that introduced this warning/error in the Swift compiler and SwiftSyntax, I just found out that <access-control-modifier> (set) is only one special case. The warning/error is actually more general and applies to all modifiers and attributes likewise, e.g. @available (*, deprecated) or nonisolated (unsafe).

For the attribute case, we could also check that there is no trivia between the @ sign and the attribute name as this is another related compiler diagnostic. It also seems that while

let closure1 = { @MainActor (a, b) in
}

leads to the warning/error,

let closure2 = { @MainActor 
   (a, b) in
}

does not. In other words, a line break serves as a disambiguator.

I hope this isn't too much to ask for, but it seems that only supporting all these cases makes this rule a real help in preparation for Swift 6. I'm happy to help in case of any issues. 😉

SimplyDanny avatar Jul 13 '24 11:07 SimplyDanny

Sounds good @SimplyDanny! I'll explore that today - just wanted to double-check my understanding before I continue.

First, I should should update my existing implementation to check that there is no trivia between any DeclModifier and DeclModifierDetail which would handle cases like (set) and nonisolated(unsafe)

Next, based off the examples in the commit you referenced:

struct PropertyWrapperTest {
  @MyPropertyWrapper (param: 2)  // expected-warning {{extraneous whitespace between attribute name and '('; this is an error in Swift 6}}
  var x: Int
}

let closure1 = { @MainActor (a, b) in // expected-warning {{extraneous whitespace between attribute name and '('; this is an error in Swift 6}}
}

let closure2 = { @MainActor
  (a: Int, b: Int) in
}

When I plug them into the Swift AST Explorer, I see that AttributeList and Attribute are the type we're after.

So, in addition to the existing check above, we want to add a new check for all AttributeList->Attribute->IdentifierType to ensure that there is no leading (ex. @ MainActor / @ escaping) or trailing trivia (ex. @MyPropertyWrapper (param: 2) / @MainActor (a, b))?

aryamansharda avatar Jul 13 '24 18:07 aryamansharda

Yes, you mentioned all the cases we can find in the related Swift compiler diagnostics.

SimplyDanny avatar Jul 13 '24 21:07 SimplyDanny

Not sure if this will work or not, but you might be able to avoid the Rewriter implementation by doing something like ImplicitReturnRule does with SwiftSyntaxCorrectableRule.

mildm8nnered avatar Jul 15 '24 23:07 mildm8nnered

@mildm8nnered Ah, very cool. Just updated the implementation to use that 👍

aryamansharda avatar Jul 16 '24 00:07 aryamansharda

Hey @aryamansharda, anything that's blocking this PR? I'd like to include it into the next major release. Swift 6 is not too far off. To drive this rule useable, we shouldn't wait for too long.

SimplyDanny avatar Aug 22 '24 20:08 SimplyDanny

Hey, sorry for the delay! I'll make the updates in the next day or two!

aryamansharda avatar Aug 22 '24 20:08 aryamansharda

@SimplyDanny Sorry for the delay, but I've made the requested changes. If there's any other changes or documentation changes let me know - I promise the following turn around time will be much faster.

aryamansharda avatar Aug 29 '24 22:08 aryamansharda

Thanks @aryamansharda! I only made the wording more serious to better match the error severity and the fact that these violation will be compiler errors in the future.

Once the build passes, this is ready to be merged.

SimplyDanny avatar Sep 06 '24 12:09 SimplyDanny