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

Add new opt-in no_empty_block rule #5617

Merged
merged 15 commits into from
Jun 29, 2024

Conversation

Ueeek
Copy link
Contributor

@Ueeek Ueeek commented Jun 4, 2024

resolve #5615
Add no_empty_function rule

@mildm8nnered
Copy link
Collaborator

Should init and deinit be checked as well?

@Ueeek Ueeek force-pushed the feature/no-empty-function-rule branch from 87b0f07 to bb520cd Compare June 22, 2024 23:44
@SwiftLintBot
Copy link

SwiftLintBot commented Jun 22, 2024

1672 Warnings
⚠️ This PR introduced a violation in Aerial: /Aerial/Source/Models/Hardware/ISSoundAdditions/SoundOutputManager+Properties.swift:34:15: warning: No Empty Block Violation: Code blocks should contain at least one statement or comment (no_empty_block)
⚠️ This PR introduced a violation in Aerial: /Aerial/Source/Models/Hardware/ISSoundAdditions/SoundOutputManager+Properties.swift:50:15: warning: No Empty Block Violation: Code blocks should contain at least one statement or comment (no_empty_block)
⚠️ This PR introduced a violation in Aerial: /Aerial/Source/Models/Hardware/ISSoundAdditions/SoundOutputManager.swift:35:21: warning: No Empty Block Violation: Code blocks should contain at least one statement or comment (no_empty_block)
⚠️ This PR introduced a violation in Aerial: /Aerial/Source/Views/AerialView+Player.swift:95:38: warning: No Empty Block Violation: Code blocks should contain at least one statement or comment (no_empty_block)
⚠️ This PR introduced a violation in Aerial: /Aerial/Source/Views/AerialView.swift:223:37: warning: No Empty Block Violation: Code blocks should contain at least one statement or comment (no_empty_block)
⚠️ This PR introduced a violation in Aerial: /Aerial/Source/Views/Layers/AnimationLayer.swift:24:34: warning: No Empty Block Violation: Code blocks should contain at least one statement or comment (no_empty_block)
⚠️ This PR introduced a violation in Aerial: /Aerial/Source/Views/Layers/AnimationLayer.swift:25:62: warning: No Empty Block Violation: Code blocks should contain at least one statement or comment (no_empty_block)
⚠️ This PR introduced a violation in Aerial: /Aerial/Source/Views/Layers/AnimationLayer.swift:26:42: warning: No Empty Block Violation: Code blocks should contain at least one statement or comment (no_empty_block)
⚠️ This PR introduced a violation in Aerial: /Aerial/Source/Views/Layers/AnimationTextLayer.swift:60:34: warning: No Empty Block Violation: Code blocks should contain at least one statement or comment (no_empty_block)
⚠️ This PR introduced a violation in Aerial: /Aerial/Source/Views/Layers/AnimationTextLayer.swift:61:62: warning: No Empty Block Violation: Code blocks should contain at least one statement or comment (no_empty_block)
⚠️ This PR introduced a violation in Aerial: /Aerial/Source/Views/Layers/AnimationTextLayer.swift:62:42: warning: No Empty Block Violation: Code blocks should contain at least one statement or comment (no_empty_block)
⚠️ This PR introduced a violation in Aerial: /Aerial/Source/Views/PrefPanel/InfoWeatherView.swift:136:21: warning: No Empty Block Violation: Code blocks should contain at least one statement or comment (no_empty_block)
⚠️ This PR introduced a violation in Aerial: /Aerial/Source/Views/PrefPanel/InfoWeatherView.swift:143:21: warning: No Empty Block Violation: Code blocks should contain at least one statement or comment (no_empty_block)
⚠️ This PR introduced a violation in Aerial: /Aerial/Source/Views/PrefPanel/InfoWeatherView.swift:44:38: warning: No Empty Block Violation: Code blocks should contain at least one statement or comment (no_empty_block)
⚠️ This PR introduced a violation in Aerial: /Resources/MainUI/First time setup/VideoFormatViewController.swift:30:37: warning: No Empty Block Violation: Code blocks should contain at least one statement or comment (no_empty_block)
⚠️ This PR introduced a violation in Aerial: /Resources/MainUI/Settings panels/BrightnessViewController.swift:90:84: warning: No Empty Block Violation: Code blocks should contain at least one statement or comment (no_empty_block)
⚠️ This PR introduced a violation in Alamofire: /Source/Core/DataStreamRequest.swift:546:19: warning: No Empty Block Violation: Code blocks should contain at least one statement or comment (no_empty_block)
⚠️ This PR introduced a violation in Alamofire: /Source/Core/DataStreamRequest.swift:554:19: warning: No Empty Block Violation: Code blocks should contain at least one statement or comment (no_empty_block)
⚠️ This PR introduced a violation in Alamofire: /Source/Core/HTTPHeaders.swift:32:19: warning: No Empty Block Violation: Code blocks should contain at least one statement or comment (no_empty_block)
⚠️ This PR introduced a violation in Alamofire: /Source/Features/AlamofireExtended.swift:53:13: warning: No Empty Block Violation: Code blocks should contain at least one statement or comment (no_empty_block)
⚠️ This PR introduced a violation in Alamofire: /Source/Features/AlamofireExtended.swift:59:13: warning: No Empty Block Violation: Code blocks should contain at least one statement or comment (no_empty_block)
⚠️ This PR introduced a violation in Alamofire: /Source/Features/EventMonitor.swift:231:92: warning: No Empty Block Violation: Code blocks should contain at least one statement or comment (no_empty_block)
⚠️ This PR introduced a violation in Alamofire: /Source/Features/EventMonitor.swift:234:78: warning: No Empty Block Violation: Code blocks should contain at least one statement or comment (no_empty_block)
⚠️ This PR introduced a violation in Alamofire: /Source/Features/EventMonitor.swift:239:61: warning: No Empty Block Violation: Code blocks should contain at least one statement or comment (no_empty_block)
⚠️ This PR introduced a violation in Alamofire: /Source/Features/EventMonitor.swift:240:96: warning: No Empty Block Violation: Code blocks should contain at least one statement or comment (no_empty_block)
⚠️ This PR introduced a violation in Alamofire: /Source/Features/EventMonitor.swift:244:60: warning: No Empty Block Violation: Code blocks should contain at least one statement or comment (no_empty_block)
⚠️ This PR introduced a violation in Alamofire: /Source/Features/EventMonitor.swift:247:80: warning: No Empty Block Violation: Code blocks should contain at least one statement or comment (no_empty_block)
⚠️ This PR introduced a violation in Alamofire: /Source/Features/EventMonitor.swift:248:109: warning: No Empty Block Violation: Code blocks should contain at least one statement or comment (no_empty_block)
⚠️ This PR introduced a violation in Alamofire: /Source/Features/EventMonitor.swift:249:102: warning: No Empty Block Violation: Code blocks should contain at least one statement or comment (no_empty_block)
⚠️ This PR introduced a violation in Alamofire: /Source/Features/EventMonitor.swift:250:115: warning: No Empty Block Violation: Code blocks should contain at least one statement or comment (no_empty_block)
⚠️ This PR introduced a violation in Alamofire: /Source/Features/EventMonitor.swift:251:104: warning: No Empty Block Violation: Code blocks should contain at least one statement or comment (no_empty_block)
⚠️ This PR introduced a violation in Alamofire: /Source/Features/EventMonitor.swift:254:83: warning: No Empty Block Violation: Code blocks should contain at least one statement or comment (no_empty_block)
⚠️ This PR introduced a violation in Alamofire: /Source/Features/EventMonitor.swift:258:55: warning: No Empty Block Violation: Code blocks should contain at least one statement or comment (no_empty_block)
⚠️ This PR introduced a violation in Alamofire: /Source/Features/EventMonitor.swift:263:62: warning: No Empty Block Violation: Code blocks should contain at least one statement or comment (no_empty_block)
⚠️ This PR introduced a violation in Alamofire: /Source/Features/EventMonitor.swift:266:66: warning: No Empty Block Violation: Code blocks should contain at least one statement or comment (no_empty_block)
⚠️ This PR introduced a violation in Alamofire: /Source/Features/EventMonitor.swift:267:96: warning: No Empty Block Violation: Code blocks should contain at least one statement or comment (no_empty_block)
⚠️ This PR introduced a violation in Alamofire: /Source/Features/EventMonitor.swift:268:96: warning: No Empty Block Violation: Code blocks should contain at least one statement or comment (no_empty_block)
⚠️ This PR introduced a violation in Alamofire: /Source/Features/EventMonitor.swift:271:56: warning: No Empty Block Violation: Code blocks should contain at least one statement or comment (no_empty_block)
⚠️ This PR introduced a violation in Alamofire: /Source/Features/EventMonitor.swift:274:51: warning: No Empty Block Violation: Code blocks should contain at least one statement or comment (no_empty_block)
⚠️ This PR introduced a violation in Alamofire: /Source/Features/EventMonitor.swift:275:89: warning: No Empty Block Violation: Code blocks should contain at least one statement or comment (no_empty_block)
⚠️ This PR introduced a violation in Alamofire: /Source/Features/EventMonitor.swift:276:81: warning: No Empty Block Violation: Code blocks should contain at least one statement or comment (no_empty_block)
⚠️ This PR introduced a violation in Alamofire: /Source/Features/EventMonitor.swift:277:94: warning: No Empty Block Violation: Code blocks should contain at least one statement or comment (no_empty_block)
⚠️ This PR introduced a violation in Alamofire: /Source/Features/EventMonitor.swift:278:110: warning: No Empty Block Violation: Code blocks should contain at least one statement or comment (no_empty_block)
⚠️ This PR introduced a violation in Alamofire: /Source/Features/EventMonitor.swift:279:105: warning: No Empty Block Violation: Code blocks should contain at least one statement or comment (no_empty_block)
⚠️ This PR introduced a violation in Alamofire: /Source/Features/EventMonitor.swift:280:55: warning: No Empty Block Violation: Code blocks should contain at least one statement or comment (no_empty_block)
⚠️ This PR introduced a violation in Alamofire: /Source/Features/EventMonitor.swift:281:54: warning: No Empty Block Violation: Code blocks should contain at least one statement or comment (no_empty_block)
⚠️ This PR introduced a violation in Alamofire: /Source/Features/EventMonitor.swift:282:54: warning: No Empty Block Violation: Code blocks should contain at least one statement or comment (no_empty_block)
⚠️ This PR introduced a violation in Alamofire: /Source/Features/EventMonitor.swift:283:81: warning: No Empty Block Violation: Code blocks should contain at least one statement or comment (no_empty_block)
⚠️ This PR introduced a violation in Alamofire: /Source/Features/EventMonitor.swift:284:55: warning: No Empty Block Violation: Code blocks should contain at least one statement or comment (no_empty_block)
⚠️ This PR introduced a violation in Alamofire: /Source/Features/EventMonitor.swift:285:82: warning: No Empty Block Violation: Code blocks should contain at least one statement or comment (no_empty_block)
⚠️ This PR introduced a violation in Alamofire: /Source/Features/EventMonitor.swift:286:54: warning: No Empty Block Violation: Code blocks should contain at least one statement or comment (no_empty_block)
⚠️ This PR introduced a violation in Alamofire: /Source/Features/EventMonitor.swift:287:81: warning: No Empty Block Violation: Code blocks should contain at least one statement or comment (no_empty_block)
⚠️ This PR introduced a violation in Alamofire: /Source/Features/EventMonitor.swift:292:70: warning: No Empty Block Violation: Code blocks should contain at least one statement or comment (no_empty_block)
⚠️ This PR introduced a violation in Alamofire: /Source/Features/EventMonitor.swift:293:106: warning: No Empty Block Violation: Code blocks should contain at least one statement or comment (no_empty_block)
⚠️ This PR introduced a violation in Alamofire: /Source/Features/EventMonitor.swift:294:113: warning: No Empty Block Violation: Code blocks should contain at least one statement or comment (no_empty_block)
⚠️ This PR introduced a violation in Alamofire: /Source/Features/EventMonitor.swift:298:70: warning: No Empty Block Violation: Code blocks should contain at least one statement or comment (no_empty_block)
⚠️ This PR introduced a violation in Alamofire: /Source/Features/EventMonitor.swift:299:109: warning: No Empty Block Violation: Code blocks should contain at least one statement or comment (no_empty_block)
⚠️ This PR introduced a violation in Alamofire: /Source/Features/EventMonitor.swift:300:109: warning: No Empty Block Violation: Code blocks should contain at least one statement or comment (no_empty_block)
⚠️ This PR introduced a violation in Alamofire: /Source/Features/EventMonitor.swift:301:102: warning: No Empty Block Violation: Code blocks should contain at least one statement or comment (no_empty_block)
⚠️ This PR introduced a violation in Alamofire: /Source/Features/EventMonitor.swift:302:94: warning: No Empty Block Violation: Code blocks should contain at least one statement or comment (no_empty_block)
⚠️ This PR introduced a violation in Alamofire: /Source/Features/EventMonitor.swift:303:136: warning: No Empty Block Violation: Code blocks should contain at least one statement or comment (no_empty_block)
⚠️ This PR introduced a violation in Alamofire: /Source/Features/EventMonitor.swift:304:87: warning: No Empty Block Violation: Code blocks should contain at least one statement or comment (no_empty_block)
⚠️ This PR introduced a violation in Alamofire: /Source/Features/EventMonitor.swift:309:70: warning: No Empty Block Violation: Code blocks should contain at least one statement or comment (no_empty_block)
⚠️ This PR introduced a violation in Alamofire: /Source/Features/EventMonitor.swift:310:113: warning: No Empty Block Violation: Code blocks should contain at least one statement or comment (no_empty_block)
⚠️ This PR introduced a violation in Alamofire: /Source/Features/EventMonitor.swift:311:121: warning: No Empty Block Violation: Code blocks should contain at least one statement or comment (no_empty_block)
⚠️ This PR introduced a violation in Alamofire: /Source/Features/ResponseSerialization.swift:184:19: warning: No Empty Block Violation: Code blocks should contain at least one statement or comment (no_empty_block)
⚠️ This PR introduced a violation in Alamofire: /Source/Features/ResponseSerialization.swift:83:19: warning: No Empty Block Violation: Code blocks should contain at least one statement or comment (no_empty_block)
⚠️ This PR introduced a violation in Alamofire: /Source/Features/ResponseSerialization.swift:91:19: warning: No Empty Block Violation: Code blocks should contain at least one statement or comment (no_empty_block)
⚠️ This PR introduced a violation in Alamofire: /Source/Features/ServerTrustEvaluation.swift:452:19: warning: No Empty Block Violation: Code blocks should contain at least one statement or comment (no_empty_block)
⚠️ This PR introduced a violation in Alamofire: /Source/Features/ServerTrustEvaluation.swift:454:74: warning: No Empty Block Violation: Code blocks should contain at least one statement or comment (no_empty_block)
⚠️ This PR introduced a violation in Alamofire: /Tests/NSLoggingEventMonitor.swift:31:19: warning: No Empty Block Violation: Code blocks should contain at least one statement or comment (no_empty_block)
⚠️ This PR introduced a violation in Brave: /App/iOS/Delegates/AppState.swift:116:40: warning: No Empty Block Violation: Code blocks should contain at least one statement or comment (no_empty_block)
⚠️ This PR introduced a violation in Brave: /Sources/Brave/Frontend/Browser/BrowserViewController/BVC+Playlist.swift:98:39: warning: No Empty Block Violation: Code blocks should contain at least one statement or comment (no_empty_block)
⚠️ This PR introduced a violation in Brave: /Sources/Brave/Frontend/Browser/BrowserViewController/BVC+ReaderMode.swift:27:139: warning: No Empty Block Violation: Code blocks should contain at least one statement or comment (no_empty_block)
⚠️ This PR introduced a violation in Brave: /Sources/Brave/Frontend/Browser/BrowserViewController/BVC+TabManagerDelegate.swift:163:66: warning: No Empty Block Violation: Code blocks should contain at least one statement or comment (no_empty_block)
⚠️ This PR introduced a violation in Brave: /Sources/Brave/Frontend/Browser/BrowserViewController/BVC+Wallet.swift:582:24: warning: No Empty Block Violation: Code blocks should contain at least one statement or comment (no_empty_block)
⚠️ This PR introduced a violation in Brave: /Sources/Brave/Frontend/Browser/BrowserViewController/BVC+Wallet.swift:585:25: warning: No Empty Block Violation: Code blocks should contain at least one statement or comment (no_empty_block)
⚠️ This PR introduced a violation in Brave: /Sources/Brave/Frontend/Browser/BrowserViewController/BVC+Wallet.swift:625:19: warning: No Empty Block Violation: Code blocks should contain at least one statement or comment (no_empty_block)
⚠️ This PR introduced a violation in Brave: /Sources/Brave/Frontend/Browser/BrowserViewController/BVC+Wallet.swift:628:26: warning: No Empty Block Violation: Code blocks should contain at least one statement or comment (no_empty_block)
⚠️ This PR introduced a violation in Brave: /Sources/Brave/Frontend/Browser/BrowserViewController/BVC+Wallet.swift:631:33: warning: No Empty Block Violation: Code blocks should contain at least one statement or comment (no_empty_block)
⚠️ This PR introduced a violation in Brave: /Sources/Brave/Frontend/Browser/BrowserViewController/BVC+Wallet.swift:634:73: warning: No Empty Block Violation: Code blocks should contain at least one statement or comment (no_empty_block)
⚠️ This PR introduced a violation in Brave: /Sources/Brave/Frontend/Browser/BrowserViewController/BVC+Wallet.swift:637:100: warning: No Empty Block Violation: Code blocks should contain at least one statement or comment (no_empty_block)
⚠️ This PR introduced a violation in Brave: /Sources/Brave/Frontend/Browser/BrowserViewController/BVC+Wallet.swift:640:66: warning: No Empty Block Violation: Code blocks should contain at least one statement or comment (no_empty_block)
⚠️ This PR introduced a violation in Brave: /Sources/Brave/Frontend/Browser/DownloadQueue.swift:36:17: warning: No Empty Block Violation: Code blocks should contain at least one statement or comment (no_empty_block)
⚠️ This PR introduced a violation in Brave: /Sources/Brave/Frontend/Browser/DownloadQueue.swift:37:16: warning: No Empty Block Violation: Code blocks should contain at least one statement or comment (no_empty_block)
⚠️ This PR introduced a violation in Brave: /Sources/Brave/Frontend/Browser/DownloadQueue.swift:38:17: warning: No Empty Block Violation: Code blocks should contain at least one statement or comment (no_empty_block)
⚠️ This PR introduced a violation in Brave: /Sources/Brave/Frontend/Browser/Favicons/UIImageView+Favicon.swift:58:31: warning: No Empty Block Violation: Code blocks should contain at least one statement or comment (no_empty_block)
⚠️ This PR introduced a violation in Brave: /Sources/Brave/Frontend/Browser/Handlers/AboutHomeHandler.swift:31:17: warning: No Empty Block Violation: Code blocks should contain at least one statement or comment (no_empty_block)
⚠️ This PR introduced a violation in Brave: /Sources/Brave/Frontend/Browser/Handlers/AboutHomeHandler.swift:48:17: warning: No Empty Block Violation: Code blocks should contain at least one statement or comment (no_empty_block)
⚠️ This PR introduced a violation in Brave: /Sources/Brave/Frontend/Browser/Handlers/BlockedDomainHandler.swift:15:19: warning: No Empty Block Violation: Code blocks should contain at least one statement or comment (no_empty_block)
⚠️ This PR introduced a violation in Brave: /Sources/Brave/Frontend/Browser/Handlers/IPFSSchemeHandler.swift:48:17: warning: No Empty Block Violation: Code blocks should contain at least one statement or comment (no_empty_block)
⚠️ This PR introduced a violation in Brave: /Sources/Brave/Frontend/Browser/Handlers/SessionRestoreHandler.swift:109:17: warning: No Empty Block Violation: Code blocks should contain at least one statement or comment (no_empty_block)
⚠️ This PR introduced a violation in Brave: /Sources/Brave/Frontend/Browser/Handlers/Web3DomainHandler.swift:84:17: warning: No Empty Block Violation: Code blocks should contain at least one statement or comment (no_empty_block)
⚠️ This PR introduced a violation in Brave: /Sources/Brave/Frontend/Browser/Helpers/ErrorPageHelper.swift:75:17: warning: No Empty Block Violation: Code blocks should contain at least one statement or comment (no_empty_block)
⚠️ This PR introduced a violation in Brave: /Sources/Brave/Frontend/Browser/Interstitial Pages/InternalSchemeHandler.swift:120:82: warning: No Empty Block Violation: Code blocks should contain at least one statement or comment (no_empty_block)
⚠️ This PR introduced a violation in Brave: /Sources/Brave/Frontend/Browser/Playlist/Browser/PlaylistPopoverView.swift:78:15: warning: No Empty Block Violation: Code blocks should contain at least one statement or comment (no_empty_block)
⚠️ This PR introduced a violation in Brave: /Sources/Brave/Frontend/Browser/PrivacyProtection/PrivateBrowsingManager.swift:11:17: warning: No Empty Block Violation: Code blocks should contain at least one statement or comment (no_empty_block)
⚠️ This PR introduced a violation in Brave: /Sources/Brave/Frontend/Browser/TabManager.swift:1155:75: warning: No Empty Block Violation: Code blocks should contain at least one statement or comment (no_empty_block)
⚠️ This PR introduced a violation in Brave: /Sources/Brave/Frontend/Browser/TabManager.swift:1187:97: warning: No Empty Block Violation: Code blocks should contain at least one statement or comment (no_empty_block)
⚠️ This PR introduced a violation in Brave: /Sources/Brave/Frontend/Browser/TabManager.swift:1201:66: warning: No Empty Block Violation: Code blocks should contain at least one statement or comment (no_empty_block)
⚠️ This PR introduced a violation in Brave: /Sources/Brave/Frontend/Browser/TabManager.swift:1202:69: warning: No Empty Block Violation: Code blocks should contain at least one statement or comment (no_empty_block)
⚠️ This PR introduced a violation in Brave: /Sources/Brave/Frontend/Browser/TabManager.swift:1203:55: warning: No Empty Block Violation: Code blocks should contain at least one statement or comment (no_empty_block)
⚠️ This PR introduced a violation in Brave: /Sources/Brave/Frontend/Browser/TabManager.swift:1204:82: warning: No Empty Block Violation: Code blocks should contain at least one statement or comment (no_empty_block)
⚠️ This PR introduced a violation in Brave: /Sources/Brave/Frontend/Browser/Tabs/TabTray/TabTrayController.swift:832:98: warning: No Empty Block Violation: Code blocks should contain at least one statement or comment (no_empty_block)
⚠️ This PR introduced a violation in Brave: /Sources/Brave/Frontend/Browser/Tabs/TabTray/TabTrayController.swift:833:66: warning: No Empty Block Violation: Code blocks should contain at least one statement or comment (no_empty_block)
⚠️ This PR introduced a violation in Brave: /Sources/Brave/Frontend/Browser/Tabs/TabTray/TabTrayController.swift:834:69: warning: No Empty Block Violation: Code blocks should contain at least one statement or comment (no_empty_block)
⚠️ This PR introduced a violation in Brave: /Sources/Brave/Frontend/Browser/Tabs/TabTray/TabTrayController.swift:835:55: warning: No Empty Block Violation: Code blocks should contain at least one statement or comment (no_empty_block)
⚠️ This PR introduced a violation in Brave: /Sources/Brave/Frontend/Browser/Tabs/TabTray/TabTrayController.swift:836:59: warning: No Empty Block Violation: Code blocks should contain at least one statement or comment (no_empty_block)
⚠️ This PR introduced a violation in Brave: /Sources/Brave/Frontend/Browser/Tabs/TabTray/TabTrayController.swift:837:82: warning: No Empty Block Violation: Code blocks should contain at least one statement or comment (no_empty_block)
⚠️ This PR introduced a violation in Brave: /Sources/Brave/Frontend/Browser/Toolbars/BottomToolbar/Menu/Bookmarks/AddEditBookmarkTableViewController.swift:526:85: warning: No Empty Block Violation: Code blocks should contain at least one statement or comment (no_empty_block)
⚠️ This PR introduced a violation in Brave: /Sources/Brave/Frontend/Browser/Toolbars/BottomToolbar/Menu/Bookmarks/AddEditBookmarkTableViewController.swift:530:84: warning: No Empty Block Violation: Code blocks should contain at least one statement or comment (no_empty_block)
⚠️ This PR introduced a violation in Brave: /Sources/Brave/Frontend/Browser/Toolbars/UrlBar/PlaylistURLBarButton.swift:112:45: warning: No Empty Block Violation: Code blocks should contain at least one statement or comment (no_empty_block)
⚠️ This PR introduced a violation in Brave: /Sources/Brave/Frontend/Browser/Toolbars/UrlBar/TabLocationView.swift:478:36: warning: No Empty Block Violation: Code blocks should contain at least one statement or comment (no_empty_block)
⚠️ This PR introduced a violation in Brave: /Sources/Brave/Frontend/Browser/Toolbars/UrlBar/TabLocationView.swift:481:53: warning: No Empty Block Violation: Code blocks should contain at least one statement or comment (no_empty_block)
⚠️ This PR introduced a violation in Brave: /Sources/Brave/Frontend/Browser/Toolbars/UrlBar/TabLocationView.swift:547:9: warning: No Empty Block Violation: Code blocks should contain at least one statement or comment (no_empty_block)
⚠️ This PR introduced a violation in Brave: /Sources/Brave/Frontend/Reader/ReadabilityService.swift:103:124: warning: No Empty Block Violation: Code blocks should contain at least one statement or comment (no_empty_block)
⚠️ This PR introduced a violation in Brave: /Sources/Brave/Frontend/Reader/ReadabilityService.swift:106:102: warning: No Empty Block Violation: Code blocks should contain at least one statement or comment (no_empty_block)
⚠️ This PR introduced a violation in Brave: /Sources/Brave/Frontend/Settings/Features/ShieldsPrivacy/AdvancedShieldSettings.swift:123:36: warning: No Empty Block Violation: Code blocks should contain at least one statement or comment (no_empty_block)
⚠️ This PR introduced a violation in Brave: /Sources/Brave/Frontend/Settings/Features/ShieldsPrivacy/Clearables.swift:185:10: warning: No Empty Block Violation: Code blocks should contain at least one statement or comment (no_empty_block)
⚠️ This PR introduced a violation in Brave: /Sources/Brave/Frontend/Settings/Features/ShieldsPrivacy/Clearables.swift:208:10: warning: No Empty Block Violation: Code blocks should contain at least one statement or comment (no_empty_block)
⚠️ This PR introduced a violation in Brave: /Sources/Brave/Frontend/Settings/Features/ShieldsPrivacy/Clearables.swift:231:10: warning: No Empty Block Violation: Code blocks should contain at least one statement or comment (no_empty_block)
⚠️ This PR introduced a violation in Brave: /Sources/Brave/Helpers/TabEventHandler.swift:75:47: warning: No Empty Block Violation: Code blocks should contain at least one statement or comment (no_empty_block)
⚠️ This PR introduced a violation in Brave: /Sources/Brave/Helpers/TabEventHandler.swift:76:68: warning: No Empty Block Violation: Code blocks should contain at least one statement or comment (no_empty_block)
⚠️ This PR introduced a violation in Brave: /Sources/Brave/Helpers/TabEventHandler.swift:77:58: warning: No Empty Block Violation: Code blocks should contain at least one statement or comment (no_empty_block)
⚠️ This PR introduced a violation in Brave: /Sources/Brave/Helpers/TabEventHandler.swift:78:36: warning: No Empty Block Violation: Code blocks should contain at least one statement or comment (no_empty_block)
⚠️ This PR introduced a violation in Brave: /Sources/Brave/Helpers/TabEventHandler.swift:79:36: warning: No Empty Block Violation: Code blocks should contain at least one statement or comment (no_empty_block)
⚠️ This PR introduced a violation in Brave: /Sources/Brave/Helpers/TabEventHandler.swift:80:32: warning: No Empty Block Violation: Code blocks should contain at least one statement or comment (no_empty_block)
⚠️ This PR introduced a violation in Brave: /Sources/Brave/Helpers/TabEventHandler.swift:81:53: warning: No Empty Block Violation: Code blocks should contain at least one statement or comment (no_empty_block)
⚠️ This PR introduced a violation in Brave: /Sources/Brave/WebFilters/DebouncingService.swift:241:10: warning: No Empty Block Violation: Code blocks should contain at least one statement or comment (no_empty_block)
⚠️ This PR introduced a violation in Brave: /Sources/BraveUI/Popover/PopoverContentComponent.swift:41:66: warning: No Empty Block Violation: Code blocks should contain at least one statement or comment (no_empty_block)
⚠️ This PR introduced a violation in Brave: /Sources/BraveUI/SwiftUI/FixedHeightHostingPanModalController.swift:70:9: warning: No Empty Block Violation: Code blocks should contain at least one statement or comment (no_empty_block)
⚠️ This PR introduced a violation in Brave: /Sources/BraveUI/SwiftUI/TableCellButtonStyle.swift:12:17: warning: No Empty Block Violation: Code blocks should contain at least one statement or comment (no_empty_block)
⚠️ This PR introduced a violation in Brave: /Sources/BraveUI/SwiftUI/UIKitController.swift:34:89: warning: No Empty Block Violation: Code blocks should contain at least one statement or comment (no_empty_block)
⚠️ Danger found 1672 violations with this PR. Due to GitHub's max issue comment size, the number shown has been truncated to 133.
17 Messages
📖 Linting Aerial with this PR took 0.68s vs 0.7s on main (2% faster)
📖 Linting Alamofire with this PR took 0.91s vs 0.92s on main (1% faster)
📖 Linting Brave with this PR took 5.19s vs 5.12s on main (1% slower)
📖 Linting DuckDuckGo with this PR took 2.91s vs 2.88s on main (1% slower)
📖 Linting Firefox with this PR took 8.07s vs 8.09s on main (0% faster)
📖 Linting Kickstarter with this PR took 6.8s vs 6.84s on main (0% faster)
📖 Linting Moya with this PR took 0.42s vs 0.4s on main (4% slower)
📖 Linting NetNewsWire with this PR took 1.81s vs 1.84s on main (1% faster)
📖 Linting Nimble with this PR took 0.56s vs 0.57s on main (1% faster)
📖 Linting PocketCasts with this PR took 6.09s vs 6.11s on main (0% faster)
📖 Linting Quick with this PR took 0.34s vs 0.34s on main (0% slower)
📖 Linting Realm with this PR took 3.42s vs 3.38s on main (1% slower)
📖 Linting Sourcery with this PR took 1.72s vs 1.78s on main (3% faster)
📖 Linting Swift with this PR took 3.13s vs 3.11s on main (0% slower)
📖 Linting VLC with this PR took 0.91s vs 0.93s on main (2% faster)
📖 Linting Wire with this PR took 12.11s vs 12.08s on main (0% slower)
📖 Linting WordPress with this PR took 8.97s vs 8.88s on main (1% slower)

Generated by 🚫 Danger

Copy link
Collaborator

@SimplyDanny SimplyDanny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for implementing the rule!

Such a check would actually also make sense for defer blocks and empty struct/class/... declarations. That can be up to an extension. However, to be prepared a name like NoEmptyBlockRule would leave room for these cases.

@SimplyDanny
Copy link
Collaborator

Such a check would actually also make sense for defer blocks and empty struct/class/... declarations. That can be up to an extension. However, to be prepared a name like NoEmptyBlockRule would leave room for these cases.

... and to catch blocks as well like requested in #5634.

@SimplyDanny SimplyDanny mentioned this pull request Jun 23, 2024
2 tasks
@Ueeek
Copy link
Contributor Author

Ueeek commented Jun 27, 2024

@SimplyDanny Thank you for reviewing ~.
I fixed the review points.
Also, support catch and defer as well.
And change the rule name as suggested!

@Ueeek Ueeek requested a review from SimplyDanny June 27, 2024 11:35
CHANGELOG.md Outdated
@@ -15,6 +15,9 @@
* Linting got around 20% faster due to the praisworthy performance
improvements done in the [SwiftSyntax](https://github.com/apple/swift-syntax)
library.
* Add `no_empty_block` default rule to validate that `function`, `init`, `deinit`, `catch` and `defer` should not have empty code block. They should at least contain a comment.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably want to wrap this text the same as the rest of the file

@@ -3,7 +3,7 @@ public struct Stack<Element> {
private var elements = [Element]()

/// Creates an empty `Stack`.
public init() {}
public init() { /* Publish no-op initializer */ }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is a legitimate exception, because it's making the constructor public, could we detect and ignore it. I think this would only apply to init as far as I can think of.

@@ -12,7 +12,7 @@ public final class RuleRegistry: @unchecked Sendable {
/// accessed will not work.
public private(set) lazy var list = RuleList(rules: registeredRules)

private init() {}
private init() { /* To guarantee that this is singleton. */ }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also maybe this could be an exception too

@@ -1,7 +1,7 @@
package struct SuperfluousDisableCommandRule: SourceKitFreeRule {
package var configuration = SeverityConfiguration<Self>(.warning)

package init() {}
package init() { /* Make initializer as accessible as its type. */ }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe here too - if an init has any accessibility modifier apart from internal, then there is a good reason it might be empty.

@SimplyDanny
Copy link
Collaborator

Regarding accessibility modifiers on initializers: While it might be true that explicit modifiers have a potential meaning and are there for a good reason, it's not too easy to find out if the modifier is really required. See how I struggle in #5048 for example and consider

private struct S {
    private init() {}
}

where the private on the initializer is redundant.

So in the first shot of this rule, I'd require the comment in every empty block disregarding access control modifiers. It also doesn't hurt to enforce an explaining comment for these cases. Later we can add this specialization optionally.

@SimplyDanny
Copy link
Collaborator

Any reason why

do {}
for _ in 1..<12 {}
while i < 12 {}

should not trigger the rule?

@Ueeek
Copy link
Contributor Author

Ueeek commented Jun 29, 2024

@SimplyDanny Thank you for check again.
Instead of validating each syntax, validate CodeBlockSyntax so that we can support all type of CodeBlocks.(Accessor, DoCatch, Defer, Deinit, For, Function, if-else, init, repeat and while).

@mildm8nnered Thank you for mention about init.
As had discussion above, don't support accessibility modifiers on initializers for now.

Copy link
Collaborator

@SimplyDanny SimplyDanny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a few more nits. Other than that, it looks good.

Instead of validating each syntax, validate CodeBlockSyntax so that we can support all type of CodeBlocks.(Accessor, DoCatch, Defer, Deinit, For, Function, if-else, init, repeat and while).

Very good! 👍

CHANGELOG.md Outdated Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
@Ueeek Ueeek force-pushed the feature/no-empty-function-rule branch from 40c3b86 to 73e3d95 Compare June 29, 2024 10:48
@Ueeek
Copy link
Contributor Author

Ueeek commented Jun 29, 2024

@mildm8nnered @SimplyDanny Thank you for comments! Fixed all point!

@SimplyDanny
Copy link
Collaborator

Awesome first contribution! Thank you, @Ueeek.

@SimplyDanny SimplyDanny merged commit aa9f474 into realm:main Jun 29, 2024
12 checks passed
@SimplyDanny SimplyDanny changed the title add opt-in non_empty_function rule Add new opt-in no_empty_block rule Jun 29, 2024
@marcelofabri
Copy link
Collaborator

I think it’s a bad idea to enable this rule by default. Besides the initializer cases that were caught here, a common case would be creating mock types that need to conform to a protocol, but don’t care about a specific method.

@SimplyDanny
Copy link
Collaborator

I think it’s a bad idea to enable this rule by default. Besides the initializer cases that were caught here, a common case would be creating mock types that need to conform to a protocol, but don’t care about a specific method.

I have no strong opinion on that. In my world, all rules could be optional and I enable them specifically. However, it seems like people are often not aware of new optional rules. That's unfortunate. So having some default rules (with a low false positive rate) is actually a nice way to avoid helpful and likeable rules being unused.

Mocks usually appear in test code. Isn't it fine then to disable the rule in these files?

@marcelofabri
Copy link
Collaborator

I think it’s a bad idea to enable this rule by default. Besides the initializer cases that were caught here, a common case would be creating mock types that need to conform to a protocol, but don’t care about a specific method.

I have no strong opinion on that. In my world, all rules could be optional and I enable them specifically. However, it seems like people are often not aware of new optional rules. That's unfortunate. So having some default rules (with a low false positive rate) is actually a nice way to avoid helpful and likeable rules being unused.

Mocks usually appear in test code. Isn't it fine then to disable the rule in these files?

It’s a big ask to disable the rule in some files in a large enough codebase. The number of violations in OSS check tells me this should be opt-in.

@SimplyDanny
Copy link
Collaborator

I think it’s a bad idea to enable this rule by default. Besides the initializer cases that were caught here, a common case would be creating mock types that need to conform to a protocol, but don’t care about a specific method.

I have no strong opinion on that. In my world, all rules could be optional and I enable them specifically. However, it seems like people are often not aware of new optional rules. That's unfortunate. So having some default rules (with a low false positive rate) is actually a nice way to avoid helpful and likeable rules being unused.
Mocks usually appear in test code. Isn't it fine then to disable the rule in these files?

It’s a big ask to disable the rule in some files in a large enough codebase. The number of violations in OSS check tells me this should be opt-in.

What about adding a configuration that allows to disable the rule for certain constructs? Options could be initializer_bodies (which includes deinitializers), function_bodies and statement_blocks (which includes if, for, defer, ...).

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

Successfully merging this pull request may close these issues.

Rule Request: No Empty Function
5 participants