Skip to content

Add opt-in unneeded_throws_rethrows rule #6069

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

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

tonyskansf
Copy link

Add a new opt-in rule that detects unnecessary throws, helping avoid misleading definitions and requirements for the caller to write unnecessary error handling.

@SwiftLintBot
Copy link

SwiftLintBot commented Apr 28, 2025

3329 Warnings
⚠️ Big PR
⚠️ This PR introduced a violation in Alamofire: /Source/Core/URLConvertible+URLRequestConvertible.swift:51:25: Warning: The body of this function does not throw any error (unneeded_throws_rethrows)
⚠️ This PR introduced a violation in Alamofire: /Source/Core/URLConvertible+URLRequestConvertible.swift:84:32: Warning: The body of this function does not throw any error (unneeded_throws_rethrows)
⚠️ This PR introduced a violation in Alamofire: /Source/Core/UploadRequest.swift:168:36: Warning: The body of this function does not throw any error (unneeded_throws_rethrows)
⚠️ This PR introduced a violation in Alamofire: /Source/Core/DataStreamRequest.swift:554:41: Warning: The body of this function does not throw any error (unneeded_throws_rethrows)
⚠️ This PR introduced a violation in Alamofire: /Source/Core/DataStreamRequest.swift:562:41: Warning: The body of this function does not throw any error (unneeded_throws_rethrows)
⚠️ This PR introduced a violation in Alamofire: /Source/Features/ServerTrustEvaluation.swift:447:67: Warning: The body of this function does not throw any error (unneeded_throws_rethrows)
⚠️ This PR introduced a violation in Alamofire: /Source/Features/ResponseSerialization.swift:85:42: Warning: The body of this function does not throw any error (unneeded_throws_rethrows)
⚠️ This PR introduced a violation in Alamofire: /Source/Features/ResponseSerialization.swift:93:42: Warning: The body of this function does not throw any error (unneeded_throws_rethrows)
⚠️ This PR introduced a violation in Alamofire: /Tests/UploadTests.swift:360:73: Warning: The body of this function does not throw any error (unneeded_throws_rethrows)
⚠️ This PR introduced a violation in Alamofire: /Tests/SessionTests.swift:1283:86: Warning: The body of this function does not throw any error (unneeded_throws_rethrows)
⚠️ This PR introduced a violation in Alamofire: /Tests/SessionTests.swift:1338:88: Warning: The body of this function does not throw any error (unneeded_throws_rethrows)
⚠️ This PR introduced a violation in Alamofire: /Tests/ConcurrencyTests.swift:767:53: Warning: The body of this function does not throw any error (unneeded_throws_rethrows)
⚠️ This PR introduced a violation in Alamofire: /Tests/ConcurrencyTests.swift:783:48: Warning: The body of this function does not throw any error (unneeded_throws_rethrows)
⚠️ This PR introduced a violation in Alamofire: /Tests/ResponseSerializationTests.swift:1188:112: Warning: The body of this function does not throw any error (unneeded_throws_rethrows)
⚠️ This PR introduced a violation in Alamofire: /Tests/ResponseSerializationTests.swift:1211:39: Warning: The body of this function does not throw any error (unneeded_throws_rethrows)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Plugins/IntentBuilderPlugin/IntentBuilderPlugin.swift:11:74: Warning: The body of this function does not throw any error (unneeded_throws_rethrows)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Plugins/LeoAssetsPlugin/LeoAssetsPlugin.swift:13:74: Warning: The body of this function does not throw any error (unneeded_throws_rethrows)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Tests/ClientTests/User Scripts/RandomConfigurationTests.swift:12:50: Warning: The body of this function does not throw any error (unneeded_throws_rethrows)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Tests/ClientTests/User Scripts/RandomConfigurationTests.swift:39:64: Warning: The body of this function does not throw any error (unneeded_throws_rethrows)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Tests/ClientTests/User Scripts/RandomConfigurationTests.swift:64:64: Warning: The body of this function does not throw any error (unneeded_throws_rethrows)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Tests/ClientTests/User Scripts/RandomConfigurationTests.swift:94:48: Warning: The body of this function does not throw any error (unneeded_throws_rethrows)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Tests/ClientTests/ClientTests.swift:16:34: Warning: The body of this function does not throw any error (unneeded_throws_rethrows)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Tests/ClientTests/DomainUserScriptTests.swift:12:41: Warning: The body of this function does not throw any error (unneeded_throws_rethrows)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Tests/ClientTests/DomainUserScriptTests.swift:39:39: Warning: The body of this function does not throw any error (unneeded_throws_rethrows)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Tests/ClientTests/PlaylistTests.swift:13:47: Warning: The body of this function does not throw any error (unneeded_throws_rethrows)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Tests/ClientTests/PlaylistTests.swift:34:41: Warning: The body of this function does not throw any error (unneeded_throws_rethrows)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Tests/ClientTests/UniversalLinkManagerTests.swift:13:31: Warning: The body of this function does not throw any error (unneeded_throws_rethrows)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Tests/ClientTests/PageDataTests.swift:19:38: Warning: The body of this function does not throw any error (unneeded_throws_rethrows)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Tests/ClientTests/PageDataTests.swift:128:36: Warning: The body of this function does not throw any error (unneeded_throws_rethrows)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Tests/ClientTests/Web Filters/ResourceDownloaderTests.swift:11:41: Warning: The body of this function does not throw any error (unneeded_throws_rethrows)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Tests/ClientTests/Web Filters/ResourceDownloaderTests.swift:67:37: Warning: The body of this function does not throw any error (unneeded_throws_rethrows)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Tests/ClientTests/Web Filters/WebsiteRedirectsTests.swift:14:34: Warning: The body of this function does not throw any error (unneeded_throws_rethrows)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Tests/ClientTests/Web Filters/WebsiteRedirectsTests.swift:19:37: Warning: The body of this function does not throw any error (unneeded_throws_rethrows)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Tests/ClientTests/Web Filters/ResourceDownloaderStreamTests.swift:11:45: Warning: The body of this function does not throw any error (unneeded_throws_rethrows)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Tests/ClientTests/Web Filters/ResourceDownloaderStreamTests.swift:41:40: Warning: The body of this function does not throw any error (unneeded_throws_rethrows)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Tests/ClientTests/InitialSearchEnginesTests.swift:20:28: Warning: The body of this function does not throw any error (unneeded_throws_rethrows)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Tests/ClientTests/InitialSearchEnginesTests.swift:46:28: Warning: The body of this function does not throw any error (unneeded_throws_rethrows)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Tests/ClientTests/InitialSearchEnginesTests.swift:55:39: Warning: The body of this function does not throw any error (unneeded_throws_rethrows)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Tests/ClientTests/InitialSearchEnginesTests.swift:82:19: Warning: The body of this function does not throw any error (unneeded_throws_rethrows)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Tests/ClientTests/InitialSearchEnginesTests.swift:116:19: Warning: The body of this function does not throw any error (unneeded_throws_rethrows)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Tests/ClientTests/InitialSearchEnginesTests.swift:150:19: Warning: The body of this function does not throw any error (unneeded_throws_rethrows)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Tests/ClientTests/InitialSearchEnginesTests.swift:183:19: Warning: The body of this function does not throw any error (unneeded_throws_rethrows)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Tests/ClientTests/InitialSearchEnginesTests.swift:217:19: Warning: The body of this function does not throw any error (unneeded_throws_rethrows)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Tests/ClientTests/InitialSearchEnginesTests.swift:251:19: Warning: The body of this function does not throw any error (unneeded_throws_rethrows)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Tests/ClientTests/InitialSearchEnginesTests.swift:283:19: Warning: The body of this function does not throw any error (unneeded_throws_rethrows)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Tests/ClientTests/Web Filters/GroupedAdBlockEngineTests.swift:60:47: Warning: The body of this function does not throw any error (unneeded_throws_rethrows)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Tests/ClientTests/Web Filters/GroupedAdBlockEngineTests.swift:95:37: Warning: The body of this function does not throw any error (unneeded_throws_rethrows)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Tests/ClientTests/Web Filters/GroupedAdBlockEngineTests.swift:168:26: Warning: The body of this function does not throw any error (unneeded_throws_rethrows)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Tests/ClientTests/Helpers/DefaultBrowserHelperTests.swift:13:31: Warning: The body of this function does not throw any error (unneeded_throws_rethrows)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Tests/ClientTests/Helpers/BraveSkusWebHelperTests.swift:80:47: Warning: The body of this function does not throw any error (unneeded_throws_rethrows)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Tests/ClientTests/AdBlockGroupsManagerTests.swift:26:43: Warning: The body of this function does not throw any error (unneeded_throws_rethrows)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Tests/ClientTests/AdBlockGroupsManagerTests.swift:120:40: Warning: The body of this function does not throw any error (unneeded_throws_rethrows)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Tests/AIChatTests/AIChatTest.swift:13:39: Warning: The body of this function does not throw any error (unneeded_throws_rethrows)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Tests/AIChatTests/AIChatTest.swift:42:42: Warning: The body of this function does not throw any error (unneeded_throws_rethrows)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Tests/AIChatTests/AIChatTest.swift:103:29: Warning: The body of this function does not throw any error (unneeded_throws_rethrows)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Tests/AIChatTests/AIChatTest.swift:149:32: Warning: The body of this function does not throw any error (unneeded_throws_rethrows)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Tests/AIChatTests/AIChatTest.swift:195:32: Warning: The body of this function does not throw any error (unneeded_throws_rethrows)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Tests/AIChatTests/AIChatTest.swift:236:30: Warning: The body of this function does not throw any error (unneeded_throws_rethrows)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Tests/BraveTalkTests/BraveTalkJitsiTranscriptProcessorTests.swift:17:34: Warning: The body of this function does not throw any error (unneeded_throws_rethrows)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Tests/PlaylistUITests/PlayerModelTests.swift:70:42: Warning: The body of this function does not throw any error (unneeded_throws_rethrows)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Tests/BrowserMenuTests/BrowserMenuTests.swift:300:51: Warning: The body of this function does not throw any error (unneeded_throws_rethrows)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Sources/BraveWidgetsModels/LockScreenFavoriteIntentHandler.swift:14:11: Warning: The body of this function does not throw any error (unneeded_throws_rethrows)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Sources/Playlist/PlaylistManager.swift:968:48: Warning: The body of this function does not throw any error (unneeded_throws_rethrows)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Sources/Web/Chromium/ChromiumTabState.swift:430:45: Warning: The body of this function does not throw any error (unneeded_throws_rethrows)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Sources/BraveStore/Subscription/SDK/AppStoreSDK.swift:448:53: Warning: The body of this function does not throw any error (unneeded_throws_rethrows)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Sources/BraveStore/Subscription/SDK/AppStoreSDK.swift:471:63: Warning: The body of this function does not throw any error (unneeded_throws_rethrows)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Sources/Shared/Extensions/URLExtensions.swift:358:57: Warning: The body of this function does not throw any error (unneeded_throws_rethrows)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Sources/Brave/Frontend/Reader/ReaderModeCache.swift:44:64: Warning: The body of this function does not throw any error (unneeded_throws_rethrows)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Sources/Brave/Frontend/Settings/Features/ShieldsPrivacy/Clearables.swift:121:22: Warning: The body of this function does not throw any error (unneeded_throws_rethrows)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Sources/Brave/Frontend/Settings/Features/ShieldsPrivacy/Clearables.swift:143:22: Warning: The body of this function does not throw any error (unneeded_throws_rethrows)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Sources/Brave/Frontend/Settings/Features/ShieldsPrivacy/Clearables.swift:161:22: Warning: The body of this function does not throw any error (unneeded_throws_rethrows)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Sources/Brave/Frontend/Settings/Features/ShieldsPrivacy/Clearables.swift:190:22: Warning: The body of this function does not throw any error (unneeded_throws_rethrows)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Sources/Brave/Frontend/Settings/Features/ShieldsPrivacy/Clearables.swift:203:22: Warning: The body of this function does not throw any error (unneeded_throws_rethrows)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Sources/Brave/Frontend/Settings/Features/ShieldsPrivacy/Clearables.swift:226:22: Warning: The body of this function does not throw any error (unneeded_throws_rethrows)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Sources/Brave/Frontend/Settings/Features/ShieldsPrivacy/Clearables.swift:249:22: Warning: The body of this function does not throw any error (unneeded_throws_rethrows)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Sources/Brave/Frontend/Settings/Features/ShieldsPrivacy/Clearables.swift:266:22: Warning: The body of this function does not throw any error (unneeded_throws_rethrows)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Sources/Brave/Frontend/Brave Translate/BraveTranslateTabHelper.swift:290:27: Warning: The body of this function does not throw any error (unneeded_throws_rethrows)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Sources/Brave/Frontend/Browser/FrequencyQuery.swift:112:59: Warning: The body of this function does not throw any error (unneeded_throws_rethrows)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Sources/Brave/Frontend/Browser/Search/SearchEngines.swift:397:46: Warning: The body of this function does not throw any error (unneeded_throws_rethrows)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Sources/Brave/WebFilters/DownloadResourceInterface.swift:79:43: Warning: The body of this function does not throw any error (unneeded_throws_rethrows)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Sources/Brave/WebFilters/DownloadResourceInterface.swift:104:40: Warning: The body of this function does not throw any error (unneeded_throws_rethrows)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Sources/Brave/WebFilters/AdBlock/AdBlockEngineManager.swift:532:84: Warning: The body of this function does not throw any error (unneeded_throws_rethrows)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Sources/Brave/WebFilters/URLMatcher/URLMatcher.swift:188:38: Warning: The initializer does not throw any error (unneeded_throws_rethrows)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Sources/BraveShared/Extensions/URLExtensions.swift:257:79: Warning: The body of this function does not throw any error (unneeded_throws_rethrows)
⚠️ This PR introduced a violation in DuckDuckGo: /macOS/LocalPackages/UDSHelper/Tests/UDSHelperTests/UDSMessageTests.swift:23:24: Warning: The body of this function does not throw any error (unneeded_throws_rethrows)
⚠️ This PR introduced a violation in DuckDuckGo: /macOS/SyncE2EUITests/CriticalPathsTests.swift:111:37: Warning: The body of this function does not throw any error (unneeded_throws_rethrows)
⚠️ This PR introduced a violation in DuckDuckGo: /macOS/SyncE2EUITests/CriticalPathsTests.swift:136:38: Warning: The body of this function does not throw any error (unneeded_throws_rethrows)
⚠️ This PR introduced a violation in DuckDuckGo: /macOS/LocalPackages/Freemium/Tests/FreemiumTests/FreemiumDBPUserStateManagerTests.swift:37:36: Warning: The body of this function does not throw any error (unneeded_throws_rethrows)
⚠️ This PR introduced a violation in DuckDuckGo: /macOS/LocalPackages/Freemium/Tests/FreemiumTests/FreemiumDBPUserStateManagerTests.swift:41:32: Warning: The body of this function does not throw any error (unneeded_throws_rethrows)
⚠️ This PR introduced a violation in DuckDuckGo: /macOS/LocalPackages/Freemium/Tests/FreemiumTests/FreemiumDBPUserStateManagerTests.swift:53:32: Warning: The body of this function does not throw any error (unneeded_throws_rethrows)
⚠️ This PR introduced a violation in DuckDuckGo: /macOS/LocalPackages/Freemium/Tests/FreemiumTests/FreemiumDBPUserStateManagerTests.swift:67:47: Warning: The body of this function does not throw any error (unneeded_throws_rethrows)
⚠️ This PR introduced a violation in DuckDuckGo: /macOS/LocalPackages/Freemium/Tests/FreemiumTests/FreemiumDBPUserStateManagerTests.swift:79:47: Warning: The body of this function does not throw any error (unneeded_throws_rethrows)
⚠️ This PR introduced a violation in DuckDuckGo: /macOS/LocalPackages/Freemium/Tests/FreemiumTests/FreemiumDBPUserStateManagerTests.swift:93:57: Warning: The body of this function does not throw any error (unneeded_throws_rethrows)
⚠️ This PR introduced a violation in DuckDuckGo: /macOS/LocalPackages/Freemium/Tests/FreemiumTests/FreemiumDBPUserStateManagerTests.swift:105:57: Warning: The body of this function does not throw any error (unneeded_throws_rethrows)
⚠️ This PR introduced a violation in DuckDuckGo: /macOS/LocalPackages/Freemium/Tests/FreemiumTests/FreemiumDBPUserStateManagerTests.swift:119:47: Warning: The body of this function does not throw any error (unneeded_throws_rethrows)
⚠️ This PR introduced a violation in DuckDuckGo: /macOS/LocalPackages/Freemium/Tests/FreemiumTests/FreemiumDBPUserStateManagerTests.swift:131:47: Warning: The body of this function does not throw any error (unneeded_throws_rethrows)
⚠️ This PR introduced a violation in DuckDuckGo: /macOS/LocalPackages/Freemium/Tests/FreemiumTests/FreemiumDBPUserStateManagerTests.swift:145:48: Warning: The body of this function does not throw any error (unneeded_throws_rethrows)
⚠️ This PR introduced a violation in DuckDuckGo: /macOS/LocalPackages/Freemium/Tests/FreemiumTests/FreemiumDBPUserStateManagerTests.swift:157:48: Warning: The body of this function does not throw any error (unneeded_throws_rethrows)
⚠️ This PR introduced a violation in DuckDuckGo: /macOS/LocalPackages/Freemium/Tests/FreemiumTests/FreemiumDBPUserStateManagerTests.swift:171:37: Warning: The body of this function does not throw any error (unneeded_throws_rethrows)
⚠️ This PR introduced a violation in DuckDuckGo: /macOS/LocalPackages/Freemium/Tests/FreemiumTests/FreemiumDBPUserStateManagerTests.swift:230:51: Warning: The body of this function does not throw any error (unneeded_throws_rethrows)
⚠️ This PR introduced a violation in DuckDuckGo: /macOS/LocalPackages/Freemium/Tests/FreemiumTests/FreemiumDBPUserStateManagerTests.swift:242:51: Warning: The body of this function does not throw any error (unneeded_throws_rethrows)
⚠️ This PR introduced a violation in DuckDuckGo: /macOS/LocalPackages/NetworkProtectionMac/Tests/NetworkProtectionUITests/NetworkProtectionStatusBarMenuTests.swift:38:51: Warning: The body of this function does not throw any error (unneeded_throws_rethrows)
⚠️ This PR introduced a violation in DuckDuckGo: /macOS/LocalPackages/NetworkProtectionMac/Tests/NetworkProtectionUITests/TunnelControllerViewModelTests.swift:106:51: Warning: The body of this function does not throw any error (unneeded_throws_rethrows)
⚠️ This PR introduced a violation in DuckDuckGo: /macOS/LocalPackages/NetworkProtectionMac/Tests/NetworkProtectionUITests/TunnelControllerViewModelTests.swift:116:57: Warning: The body of this function does not throw any error (unneeded_throws_rethrows)
⚠️ This PR introduced a violation in DuckDuckGo: /macOS/LocalPackages/NetworkProtectionMac/Tests/NetworkProtectionUITests/TunnelControllerViewModelTests.swift:140:58: Warning: The body of this function does not throw any error (unneeded_throws_rethrows)
⚠️ This PR introduced a violation in DuckDuckGo: /macOS/LocalPackages/NetworkProtectionMac/Tests/NetworkProtectionUITests/TunnelControllerViewModelTests.swift:164:54: Warning: The body of this function does not throw any error (unneeded_throws_rethrows)
⚠️ This PR introduced a violation in DuckDuckGo: /macOS/LocalPackages/NetworkProtectionMac/Tests/NetworkProtectionUITests/TunnelControllerViewModelTests.swift:197:55: Warning: The body of this function does not throw any error (unneeded_throws_rethrows)
⚠️ This PR introduced a violation in DuckDuckGo: /macOS/LocalPackages/NetworkProtectionMac/Tests/NetworkProtectionUITests/TunnelControllerViewModelTests.swift:219:49: Warning: The body of this function does not throw any error (unneeded_throws_rethrows)
⚠️ This PR introduced a violation in DuckDuckGo: /macOS/LocalPackages/NetworkProtectionMac/Tests/NetworkProtectionUITests/TunnelControllerViewModelTests.swift:239:46: Warning: The body of this function does not throw any error (unneeded_throws_rethrows)
⚠️ This PR introduced a violation in DuckDuckGo: /macOS/LocalPackages/NetworkProtectionMac/Tests/NetworkProtectionUITests/TunnelControllerViewModelTests.swift:267:45: Warning: The body of this function does not throw any error (unneeded_throws_rethrows)
⚠️ This PR introduced a violation in DuckDuckGo: /macOS/LocalPackages/NetworkProtectionMac/Sources/NetworkProtectionProxy/FlowManagers/UDPFlowManager.swift:212:49: Warning: The body of this function does not throw any error (unneeded_throws_rethrows)
⚠️ This PR introduced a violation in DuckDuckGo: /macOS/LocalPackages/SyncUI-macOS/Tests/SyncUITests/RecoveryCodeViewModelTests.swift:24:48: Warning: The body of this function does not throw any error (unneeded_throws_rethrows)
⚠️ This PR introduced a violation in DuckDuckGo: /macOS/LocalPackages/SyncUI-macOS/Tests/SyncUITests/RecoveryCodeViewModelTests.swift:29:63: Warning: The body of this function does not throw any error (unneeded_throws_rethrows)
⚠️ This PR introduced a violation in DuckDuckGo: /macOS/LocalPackages/SyncUI-macOS/Tests/SyncUITests/RecoveryCodeViewModelTests.swift:39:39: Warning: The body of this function does not throw any error (unneeded_throws_rethrows)
⚠️ This PR introduced a violation in DuckDuckGo: /macOS/LocalPackages/HistoryView/Sources/HistoryView/DataClient.swift:89:77: Warning: The body of this function does not throw any error (unneeded_throws_rethrows)
⚠️ This PR introduced a violation in DuckDuckGo: /macOS/LocalPackages/HistoryView/Sources/HistoryView/DataClient.swift:106:74: Warning: The body of this function does not throw any error (unneeded_throws_rethrows)
⚠️ This PR introduced a violation in DuckDuckGo: /macOS/LocalPackages/HistoryView/Sources/HistoryView/DataClient.swift:111:77: Warning: The body of this function does not throw any error (unneeded_throws_rethrows)
⚠️ This PR introduced a violation in DuckDuckGo: /macOS/LocalPackages/HistoryView/Sources/HistoryView/DataClient.swift:118:76: Warning: The body of this function does not throw any error (unneeded_throws_rethrows)
⚠️ This PR introduced a violation in DuckDuckGo: /macOS/LocalPackages/HistoryView/Sources/HistoryView/DataClient.swift:125:75: Warning: The body of this function does not throw any error (unneeded_throws_rethrows)
⚠️ This PR introduced a violation in DuckDuckGo: /macOS/LocalPackages/HistoryView/Sources/HistoryView/DataClient.swift:132:70: Warning: The body of this function does not throw any error (unneeded_throws_rethrows)
⚠️ This PR introduced a violation in DuckDuckGo: /macOS/LocalPackages/HistoryView/Sources/HistoryView/DataClient.swift:140:69: Warning: The body of this function does not throw any error (unneeded_throws_rethrows)
⚠️ This PR introduced a violation in DuckDuckGo: /macOS/LocalPackages/HistoryView/Sources/HistoryView/DataClient.swift:150:76: Warning: The body of this function does not throw any error (unneeded_throws_rethrows)
⚠️ This PR introduced a violation in DuckDuckGo: /macOS/LocalPackages/HistoryView/Sources/HistoryView/DataClient.swift:157:78: Warning: The body of this function does not throw any error (unneeded_throws_rethrows)
⚠️ This PR introduced a violation in DuckDuckGo: /macOS/LocalPackages/HistoryView/Sources/HistoryView/DataClient.swift:163:80: Warning: The body of this function does not throw any error (unneeded_throws_rethrows)
⚠️ This PR introduced a violation in DuckDuckGo: /macOS/LocalPackages/BuildToolPlugins/Plugins/InputFilesChecker/InputFilesChecker.swift:101:104: Warning: The body of this function does not throw any error (unneeded_throws_rethrows)
⚠️ This PR introduced a violation in DuckDuckGo: /macOS/LocalPackages/NewTabPage/Tests/NewTabPageTests/DuckFaviconURLTests.swift:25:31: Warning: The body of this function does not throw any error (unneeded_throws_rethrows)
⚠️ This PR introduced a violation in DuckDuckGo: /macOS/LocalPackages/NewTabPage/Tests/NewTabPageTests/NewTabPageRecentActivityModelTests.swift:56:91: Warning: The body of this function does not throw any error (unneeded_throws_rethrows)
⚠️ Danger found 3329 violations with this PR. Due to GitHub's max issue comment size, the number shown has been truncated to 128.
18 Messages
📖 Building this branch resulted in a binary size of 25104.79 KiB vs 25052.41 KiB when built on main (0% larger).
📖 Linting Aerial with this PR took 1.08 s vs 1.03 s on main (4% slower).
📖 Linting Alamofire with this PR took 1.39 s vs 1.39 s on main (0% slower).
📖 Linting Brave with this PR took 9.54 s vs 9.54 s on main (0% slower).
📖 Linting DuckDuckGo with this PR took 23.49 s vs 23.53 s on main (0% faster).
📖 Linting Firefox with this PR took 11.27 s vs 11.29 s on main (0% faster).
📖 Linting Kickstarter with this PR took 10.66 s vs 10.73 s on main (0% faster).
📖 Linting Moya with this PR took 0.55 s vs 0.55 s on main (0% slower).
📖 Linting NetNewsWire with this PR took 3.12 s vs 3.14 s on main (0% faster).
📖 Linting Nimble with this PR took 0.83 s vs 0.83 s on main (0% slower).
📖 Linting PocketCasts with this PR took 8.96 s vs 8.8 s on main (1% slower).
📖 Linting Quick with this PR took 0.47 s vs 0.47 s on main (0% slower).
📖 Linting Realm with this PR took 4.82 s vs 4.84 s on main (0% faster).
📖 Linting Sourcery with this PR took 2.45 s vs 2.45 s on main (0% slower).
📖 Linting Swift with this PR took 5.62 s vs 5.63 s on main (0% faster).
📖 Linting VLC with this PR took 1.45 s vs 1.45 s on main (0% slower).
📖 Linting Wire with this PR took 21.2 s vs 21.18 s on main (0% slower).
📖 Linting WordPress with this PR took 12.55 s vs 12.53 s on main (0% slower).

Generated by 🚫 Danger

@msrutek-paylocity
Copy link

@SimplyDanny Any thoughts on this? :)

@msrutek-paylocity
Copy link

@tonyskansf It seems that some conflicts have arisen, would you mind resolving them? Thanks!

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.

Looks very good already! You thought about many special cases already. The rule also makes sense. But adding it as opt-in is important as it can cause false positives in the context of protocol implementations (and maybe more occasions).

I've added a few comments. Please also check the findings reported by the OSS scan.

@@ -12,7 +12,9 @@

### Enhancements

* None.
* Add opt-in `unneeded_throws_rethrows` rules that triggers when declarations
marked `throws`/`rethrows` never actually throw or call any throwing code.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please append two spaces to the end of the description. They are required to enforce a line break in the rendered Markdown.

static let description = RuleDescription(
identifier: "unneeded_throws_rethrows",
name: "Unneeded (re)throws keyword",
description: "Non-throwing functions/variables should not be marked as `throws` or `rethrows`",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
description: "Non-throwing functions/variables should not be marked as `throws` or `rethrows`",
description: "Non-throwing functions/properties/closures should not be marked as `throws` or `rethrows`.",

violations.append(
ReasonedRuleViolation(
position: throwsToken.positionAfterSkippingLeadingTrivia,
reason: reason,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
reason: reason,
reason: "Superfluous 'throws'; " + reason,

if let closedScope = scopes.closeScope() {
validateScope(
closedScope,
reason: "The closure type does not throw any error"
Copy link
Collaborator

Choose a reason for hiding this comment

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

To keep it short:

Suggested change
reason: "The closure type does not throw any error"
reason: "closure type does not throw any error"

final class Visitor: ViolationsSyntaxVisitor<ConfigurationType> {
private var scopes = Stack<Scope>()

override func visit(_: ProtocolDeclSyntax) -> SyntaxVisitorContinueKind {
Copy link
Collaborator

Choose a reason for hiding this comment

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

As a shortcut, you can use skippableDeclarations to ignore declarations you don't need to consider.

catch is SomeError {}
catch {}
}
"""),
Copy link
Collaborator

Choose a reason for hiding this comment

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

There should also be an example (especially a correction) making use of "typed throws".

Comment on lines +195 to +197
children(viewMode: .sourceAccurate).contains { child in
child.is(InitializerClauseSyntax.self)
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
children(viewMode: .sourceAccurate).contains { child in
child.is(InitializerClauseSyntax.self)
}
initializer != nil

Is that not possible?


var children = Set(typeAnnotation.children(viewMode: .sourceAccurate))

while let child = children.popFirst() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

That's dangerous. Consider this example:

let s: S<() throws -> Void> = S()

I think, you should be explicit about the syntax structure to match instead of iterating through all children.

reason: reason,
correction: ReasonedRuleViolation.ViolationCorrection(
start: throwsToken.positionAfterSkippingLeadingTrivia,
end: throwsToken.endPosition,
Copy link
Collaborator

Choose a reason for hiding this comment

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

You need to use endPositionBeforeTrailingTrivia here to avoid removing trailing trivia.

}

override func visitPost(_ node: FunctionCallExprSyntax) {
if node.containsTaskDeclaration {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't understand this exclusion of tasks to be honest. Could you explain?

@SimplyDanny
Copy link
Collaborator

You need to rebase onto main first to fix conflicts and build with the latest infrastructure. Ignore the conflict in GeneratedTests.swift and let the file be deleted. Eventually, run swift run swiftlint-dev rules register again.

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.

4 participants