Enable SwiftLint rule: return_value_from_void_function#25572
Closed
mokagio wants to merge 1 commit into
Closed
Conversation
Adds the rule to `only_rules` in `.swiftlint.yml` and resolves all 129 existing violations: 128 via SwiftLint's auto-fix and one manual fix in `BlogListViewModel.refresh()` (split `return try await task.value` into two statements so the function no longer returns a value). Part of the Orchard SwiftLint rollout campaign.
Collaborator
Generated by 🚫 Danger |
Contributor
There was a problem hiding this comment.
Pull request overview
Enables SwiftLint’s return_value_from_void_function rule and updates the codebase to comply by removing return <expr> patterns inside Void functions (typically return someVoidCall()), replacing them with someVoidCall() followed by an explicit return.
Changes:
- Enable
return_value_from_void_functionin SwiftLint configuration. - Mechanically rewrite
return <void-expression>into two statements (<void-expression>thenreturn) across app, modules, and tests. - Manually split the early-out in
BlogListViewModel.refresh()so theVoidfunction no longer “returns” the awaited value.
Reviewed changes
Copilot reviewed 70 out of 70 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| WordPress/WordPressShareExtension/Sources/Extensions/Tracks+ShareExtension.swift | Replace return assertionFailure(...) with assertionFailure(...); return. |
| WordPress/Classes/ViewRelated/Tags/TagsService.swift | Remove return <expr> from a Void async continuation call. |
| WordPress/Classes/ViewRelated/Stats/Subscribers/StatsSubscribersViewController.swift | Split return wpAssertionFailure(...) guard early-outs. |
| WordPress/Classes/ViewRelated/Reader/Subscriptions/ReaderSubscriptionsViewModel.swift | Split return await task.value into await task.value; return in a Void async function. |
| WordPress/Classes/ViewRelated/Reader/Detail/ReaderDetailViewController.swift | Split return wpAssertionFailure(...) guard early-out. |
| WordPress/Classes/ViewRelated/Reader/Detail/ReaderDetailCoordinator.swift | Split return wpAssertionFailure(...) guard early-out. |
| WordPress/Classes/ViewRelated/Reader/Controllers/ReaderStreamViewController.swift | Split return wpAssertionFailure(...) guard early-out. |
| WordPress/Classes/ViewRelated/Reader/Comments/ReaderCommentsViewController.swift | Split multiple return wpAssertionFailure(...) early-outs across methods. |
| WordPress/Classes/ViewRelated/Reader/Cards/ReaderRecommendedSitesCell.swift | Split return wpAssertionFailure(...) guard early-outs in button handlers. |
| WordPress/Classes/ViewRelated/Reader/Cards/ReaderPostCell.swift | Split return wpAssertionFailure(...) guard early-out. |
| WordPress/Classes/ViewRelated/Post/Utils/PostNoticePublishSuccessView.swift | Split return wpAssertionFailure(...) early-outs before presenting flows. |
| WordPress/Classes/ViewRelated/Post/Utils/PostNoticeNavigationCoordinator.swift | Split return wpAssertionFailure(...) early-outs when presenter missing. |
| WordPress/Classes/ViewRelated/Post/PostSettings/Views/PostSettingsFeaturedImageRow.swift | Split return wpAssertionFailure(...) guard early-outs in selection handling. |
| WordPress/Classes/ViewRelated/Post/PostSettings/Views/Excerpt/PostSettingsGenerateExcerptView.swift | Split return wpAssertionFailure(...) guard early-out. |
| WordPress/Classes/ViewRelated/Post/PostSettings/PostSettingsViewModel.swift | Split return wpAssertionFailure(...) guard early-outs in navigation/setup paths. |
| WordPress/Classes/ViewRelated/Post/PostEditor+Publish.swift | Split return displayMediaIsUploadingAlert() / return discardAndDismiss() guard early-outs. |
| WordPress/Classes/ViewRelated/Post/Controllers/PostListViewController.swift | Split return wpAssertionFailure(...) guard early-out. |
| WordPress/Classes/ViewRelated/Post/Controllers/AbstractPostListViewController.swift | Split return wpAssertionFailure(...) and other return <expr> early-outs. |
| WordPress/Classes/ViewRelated/Media/SiteMedia/Controllers/SiteMediaCollectionViewController.swift | Split return perform() to perform(); return. |
| WordPress/Classes/ViewRelated/Media/MediaPicker/Menu/MediaPickerMenu+ImagePlayground.swift | Split return wpAssertionFailure(...) guard early-out for availability. |
| WordPress/Classes/ViewRelated/Media/Lightbox/LightboxImageScrollView.swift | Split return centerImageView() into centerImageView(); return. |
| WordPress/Classes/ViewRelated/Me/Me Main/MeViewController.swift | Remove return <expr> from async throwing continuations returning Void. |
| WordPress/Classes/ViewRelated/Gutenberg/Utils/GutenbergFilesAppMediaSource.swift | Split return assertionFailure(...) guard early-out. |
| WordPress/Classes/ViewRelated/Gutenberg/Utils/GutenbergExternalMeidaPicker.swift | Split return assertionFailure(...) guard early-out. |
| WordPress/Classes/ViewRelated/Gutenberg/GutenbergViewController.swift | Split return showUnsupportedBlockUnexpectedErrorAlert() into call + return. |
| WordPress/Classes/ViewRelated/Comments/Views/Detail/CommentContentTableViewCell.swift | Split multiple return wpAssertionFailure(...) guard early-outs. |
| WordPress/Classes/ViewRelated/Comments/Views/Detail/CommentCellViewModel.swift | Split return wpAssertionFailure(...) guard early-out. |
| WordPress/Classes/ViewRelated/Comments/Controllers/Create/CommentCreateViewModel.swift | Split return UserDefaults.standard.set(...) into call + return. |
| WordPress/Classes/ViewRelated/Comments/Controllers/CommentDetailViewController.swift | Split return headerCell.configure(...) into call + return. |
| WordPress/Classes/ViewRelated/Blog/Subscribers/Details/SubscriberDetailsView.swift | Split return wpAssertionFailure(...) guard early-out. |
| WordPress/Classes/ViewRelated/Blog/Site Picker/BlogList/BlogListViewModel.swift | Split return try await task.value into try await task.value; return in refresh(). |
| WordPress/Classes/ViewRelated/Blog/Site Picker/BlogList/BlogListSiteView.swift | Split return wpAssertionFailure(...) guard early-out. |
| WordPress/Classes/ViewRelated/Blog/My Site/Header/HomeSiteHeaderViewController+SiteActions.swift | Split return DDLogError(...) guard early-out. |
| WordPress/Classes/ViewRelated/Blog/BloggingReminders/BloggingRemindersFlowSettingsViewController.swift | Split return wpAssertionFailure(...) guard early-out. |
| WordPress/Classes/ViewRelated/Blog/Blog Details/BlogDetailsViewController+Swift.swift | Split return wpAssertionFailure(...) guard early-out. |
| WordPress/Classes/ViewRelated/Blog/Blog Dashboard/Cards/BlogDashboardPersonalizeCardCell.swift | Split return DDLogError(...) guard early-out. |
| WordPress/Classes/Utility/WebViewController/WebKitViewController.swift | Split return completion(...) into completion(...); return. |
| WordPress/Classes/Utility/WebViewController/CookieJar.swift | Split return hasWordPressAuthCookie(...) and return completion() patterns. |
| WordPress/Classes/Utility/In-App Feedback/SubmitFeedbackViewController.swift | Split return wpAssertionFailure(...) guard early-out. |
| WordPress/Classes/System/WordPressAppDelegate.swift | Split return wpAssertionFailure(...) guard early-out. |
| WordPress/Classes/System/Root View/SplitViewRootPresenter.swift | Split return wpAssertionFailure(...) in error path. |
| WordPress/Classes/System/Root View/RootViewPresenter.swift | Split return showJetpackOverlayForDisabledEntryPoint() into call + return. |
| WordPress/Classes/System/Root View/ReaderPresenter.swift | Split return wpAssertionFailure(...) guard early-out. |
| WordPress/Classes/System/ReaderWindowManager.swift | Split return wpAssertionFailure(...) guard early-out. |
| WordPress/Classes/Services/PostRepository.swift | Split return wpAssertionFailure(...) early-outs in sync/patch paths. |
| WordPress/Classes/Services/PostCoordinator.swift | Split several return worker.log(...) / return DDLogInfo(...) early-outs. |
| WordPress/Classes/Services/EditorSettingsService.swift | Split return success() / return failure(error) into call + return. |
| WordPress/Classes/Apps/Reader/Home/ReaderHomeViewController.swift | Split return wpAssertionFailure(...) guard early-out. |
| Tests/WordPressKitTests/WordPressKitTests/Tests/RemoteTestCase.swift | Split return XCTFail(...) into XCTFail(...); return. |
| Tests/WordPressKitTests/WordPressKitTests/Tests/JetpackProxyServiceRemoteTests.swift | Split return XCTFail() guard early-outs across tests. |
| Tests/WordPressAuthenticatorTests/SingIn/LoginViewControllerTests.swift | Split return XCTFail(...) guard early-out. |
| Tests/WordPressAuthenticatorTests/SingIn/AppleAuthenticatorTests.swift | Split return XCTFail(...) guard early-out. |
| Tests/WordPressAuthenticatorTests/GoogleSignIn/URL+GoogleSignInTests.swift | Split return XCTFail(...) into XCTFail(...); return in helper asserts. |
| Tests/WordPressAuthenticatorTests/GoogleSignIn/NewGoogleAuthenticatorTests.swift | Split return XCTFail(...) in error-case guards. |
| Tests/KeystoneTests/Tests/Services/PostCoordinatorTests.swift | Split return XCTFail(...) and return try await ... into call/await + return. |
| Tests/KeystoneTests/Tests/Services/BlogServiceDeduplicationTests.swift | Split return XCTFail(...) guard early-out. |
| Tests/KeystoneTests/Tests/Features/Dashboard/BlazeCampaignsStreamTests.swift | Split return XCTFail(...) and return completion(.failure(...)) patterns. |
| Sources/WordPressData/Swift/PostMetadataContainer.swift | Split return wpAssertionFailure(...) guard early-out. |
| Sources/WordPressData/Swift/ContextManager.swift | Split return assertionFailure() guard early-out. |
| Sources/WordPressData/Swift/AbstractPost.swift | Split return wpAssertionFailure(...) guard early-out. |
| Sources/WordPressAuthenticator/Helpers/UnifiedAuth/ViewRelated/VerifyEmail/VerifyEmailViewController.swift | Split return super.styleBackground() into call + return. |
| Sources/WordPressAuthenticator/Helpers/UnifiedAuth/ViewRelated/SiteAddress/SiteCredentialsViewController.swift | Split return validateFormAndLogin() into call + return. |
| Sources/WordPressAuthenticator/Helpers/UnifiedAuth/ViewRelated/SiteAddress/SiteAddressViewController.swift | Split return displayError(...) into call + return. |
| Sources/WordPressAuthenticator/Helpers/UnifiedAuth/ViewRelated/Password/PasswordCoordinator.swift | Split return WPLogError(...) guard early-out. |
| Sources/WordPressAuthenticator/Helpers/UnifiedAuth/ViewRelated/Login/MagicLinkRequestedViewController.swift | Split return super.styleBackground() into call + return. |
| Sources/WordPressAuthenticator/Helpers/UnifiedAuth/ViewRelated/GetStarted/GetStartedViewController.swift | Split return dividerStackView.isHidden = true into assignment + return. |
| Sources/WordPressAuthenticator/Helpers/UnifiedAuth/ViewRelated/2FA/TwoFAViewController.swift | Split multiple return <expr> early-outs into call + return. |
| Sources/WordPressAuthenticator/Features/NUX/Button/NUXStackedButtonsViewController.swift | Split return dividerStackView.isHidden = true into assignment + return. |
| Modules/Sources/UITestsFoundation/XCUIElement+TapUntil.swift | Split return XCTFail(...) and return tapUntil(...) into call + return. |
| .swiftlint.yml | Enable return_value_from_void_function in only_rules. |
Comments suppressed due to low confidence (1)
Tests/WordPressAuthenticatorTests/GoogleSignIn/URL+GoogleSignInTests.swift:85
- Grammar in the failure message: "Could not created" should be "Could not create".
guard let components = URLComponents(url: url, resolvingAgainstBaseURL: false) else {
XCTFail(
"Could not created `URLComponents` from given `URL` \(url).",
file: file,
line: line
)
return
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| guard configuration.enableManualSiteCredentialLogin else { | ||
| return validateFormAndLogin() // handles login with XMLRPC normally | ||
| validateFormAndLogin() // handles login with XMLRPC normally | ||
| return // handles login with XMLRPC normally |
Comment on lines
324
to
+326
| guard let presentationDelegate else { | ||
| return wpAssertionFailure("presentationDelegate mising") | ||
| wpAssertionFailure("presentationDelegate mising") | ||
| return |
| # Type annotations are redundant when the type can be inferred. | ||
| - redundant_type_annotation | ||
|
|
||
| # Returning a value from a function declared as returning Void is disallowed. |
Comment on lines
+50
to
+55
| XCTFail( | ||
| "Could not created `URLComponents` from given `URL` \(actual).", | ||
| file: file, | ||
| line: line | ||
| ) | ||
| return |
Contributor
|
| App Name | WordPress | |
| Configuration | Release-Alpha | |
| Build Number | 32267 | |
| Version | PR #25572 | |
| Bundle ID | org.wordpress.alpha | |
| Commit | 8404288 | |
| Installation URL | 4t56if9nn4vs0 |
Contributor
|
| App Name | Jetpack | |
| Configuration | Release-Alpha | |
| Build Number | 32267 | |
| Version | PR #25572 | |
| Bundle ID | com.jetpack.alpha | |
| Commit | 8404288 | |
| Installation URL | 7dd6c36fhipmg |
Contributor
|
I don't think we need to enforce this rule. I don't mind code like |
Contributor
Author
|
@crazytonyli sounds good. Closing. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Description
Enable the SwiftLint
return_value_from_void_functionrule and resolve all 129 existing violations across the codebase.return <expr>inside a function whose return type isVoid. The expression is usually a no-op call to another Void function; splitting it into two statements makes intent explicit and avoids the trap of accidentally returning a non-Void value from a Void function later.return foo()becomesfoo()followed byreturn).BlogListViewModel.refresh(): the early-out hadreturn try await task.value; rewritten as two statements so the function no longer returns the value.Part of the Orchard SwiftLint rollout campaign.
Testing instructions
PostEditor+Publish.swift) and confirm theguard !isUploadingMedia else { ... }blocks still behave the same — the only change is statement order on the early-out branch.