Enable SwiftLint rule: explicit_init#25573
Merged
Merged
Conversation
Part of the Orchard SwiftLint rollout campaign. The rule discourages explicitly calling `.init(...)` when the type is known, preferring `Type(...)` over `Type.init(...)`. `rake lintfix` auto-fixed 36 files; no manual fixes were needed. --- Generated with the help of Claude Code, https://claude.com/claude-code Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Collaborator
Generated by 🚫 Danger |
Contributor
There was a problem hiding this comment.
Pull request overview
Enables SwiftLint’s explicit_init opt-in rule and applies automated fixes across the iOS app, modules, and test targets to remove redundant .init calls (e.g., Type.init(...) → Type(...)) in preparation for the broader SwiftLint rollout.
Changes:
- Enabled
explicit_initin.swiftlint.ymlunderonly_rules. - Auto-fixed existing
explicit_initviolations across app/module source and test files. - Normalized initializer call sites for UIKit/Foundation/CoreData/SwiftUI types and project-specific models.
Reviewed changes
Copilot reviewed 37 out of 37 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| WordPress/Classes/ViewRelated/Views/BadgeLabel.swift | Removes redundant .init from UIEdgeInsets construction. |
| WordPress/Classes/ViewRelated/Support/SupportTableViewControllerConfiguration.swift | Uses Self() instead of Self.init() for configuration creation. |
| WordPress/Classes/ViewRelated/Support/SupportTableViewController.swift | Replaces UINavigationController.init(...) with shorthand init. |
| WordPress/Classes/ViewRelated/Stats/StatsLikesListViewController.swift | Simplifies EmptyStateView initialization passed into UIHostingView. |
| WordPress/Classes/ViewRelated/Stats/Shared Views/Stats Detail/SiteStatsInsightsDetailsTableViewController.swift | Uses shorthand UINavigationController(...) init. |
| WordPress/Classes/ViewRelated/Stats/Shared Views/Stats Detail/SiteStatsDetailTableViewController.swift | Uses shorthand UINavigationController(...) init. |
| WordPress/Classes/ViewRelated/Stats/Shared Views/Post Stats/PostStatsTableViewController.swift | Uses shorthand UINavigationController(...) init. |
| WordPress/Classes/ViewRelated/Stats/Period Stats/SiteStatsPeriodViewModel.swift | Removes .init from StatsTotalRowData construction in mapping. |
| WordPress/Classes/ViewRelated/Stats/Period Stats/SiteStatsPeriodTableViewController.swift | Uses shorthand UINavigationController(...) init. |
| WordPress/Classes/ViewRelated/Stats/Insights/StatsMostPopularTimeInsightsCell.swift | Uses shorthand Calendar(identifier:) init. |
| WordPress/Classes/ViewRelated/Stats/Insights/SiteStatsInsightsViewModel.swift | Removes .init from StatsTwoColumnRowData constructions. |
| WordPress/Classes/ViewRelated/Stats/Insights/SiteStatsInsightsTableViewController.swift | Uses shorthand UINavigationController(...) init. |
| WordPress/Classes/ViewRelated/Stats/Helpers/StatsDataHelper.swift | Removes .init from StatsTotalRowData construction. |
| WordPress/Classes/ViewRelated/Reader/Theme/ReaderDisplaySettingViewController.swift | Removes .init from DSButtonStyle construction. |
| WordPress/Classes/ViewRelated/Reader/Detail/Views/ReaderDetailLikesListController.swift | Simplifies EmptyStateView initialization passed into UIHostingView. |
| WordPress/Classes/ViewRelated/Reader/Detail/Views/ReaderDetailCommentsHeader.swift | Removes redundant .init calls for presenter and UIImage(systemName:). |
| WordPress/Classes/ViewRelated/Reader/Cards/ReaderPostCellViewModel.swift | Removes .init from ReaderPost Core Data entity initialization. |
| WordPress/Classes/ViewRelated/Notifications/Views/CommentLargeButton.swift | Removes .init from UIEdgeInsets passed into pinEdges. |
| WordPress/Classes/ViewRelated/Jetpack/Login/JetpackConnectionViewModel.swift | Uses Self(...) instead of Self.init(...) for slug wrappers. |
| WordPress/Classes/ViewRelated/Domains/Domain registration/RegisterDomainDetails/ViewController/RegisterDomainDetailsViewController.swift | Removes .init from NSAttributedString creation. |
| WordPress/Classes/ViewRelated/Aztec/ViewControllers/UnknownEditorViewController.swift | Removes .init from UIEdgeInsets constant. |
| WordPress/Classes/Utility/Spotlight/SearchManager.swift | Uses shorthand EditPostViewController(post:) init. |
| WordPress/Classes/Utility/Sharing/ShareNoticeNavigationCoordinator.swift | Uses shorthand EditPostViewController(post:) init. |
| WordPress/Classes/Utility/BuildInformation/RemoteConfigParameter.swift | Uses shorthand LosslessStringConvertible init T(...). |
| WordPress/Classes/Utility/BackgroundTasks/WeeklyRoundupBackgroundTask.swift | Removes .init from TimeInterval(-1) usage. |
| WordPress/Classes/Services/AccountSettingsService.swift | Removes .init from AccountSettings(managed:) creation. |
| WordPress/Classes/Models/Blog/BlogSettings+DateAndTimeFormat.swift | Uses shorthand Calendar(identifier:) init. |
| Tests/WordPressKitTests/WordPressKitTests/Tests/IPLocationRemoteTests.swift | Uses shorthand URLSession(configuration:) init. |
| Tests/WordPressKitTests/CoreAPITests/WordPressComRestApiTests.swift | Removes .init from HTTPStubsResponse(error:) creation. |
| Tests/KeystoneTests/Tests/Features/Stats/StatsMockDataLoader.swift | Uses shorthand JSONObject(fromFileNamed:) initializer call. |
| Tests/KeystoneTests/Tests/Features/Domains/AllDomainsListItemViewModelTests.swift | Uses shorthand Date(timeIntervalSinceNow:) init. |
| Tests/KeystoneTests/Helpers/NSManagedObject+Fixture.swift | Uses shorthand Core Data Self(context:) init. |
| Tests/KeystoneTests/Helpers/ModelTestHelper.swift | Uses shorthand Core Data Blog(context:) / WPAccount(context:) init. |
| Modules/Tests/WordPressSharedTests/WPUserAgentTests.swift | Uses shorthand String(format:...) init. |
| Modules/Sources/WordPressKitModels/RemoteVideoPressVideo.swift | Removes .init from VideoPressPrivacySetting(rawValue:). |
| Modules/Sources/WordPressKitModels/RemoteUser+Likes.swift | Uses shorthand RemoteLikeUserPreferredBlog(dictionary:) init. |
| .swiftlint.yml | Enables explicit_init rule in the opt-in only_rules list. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Contributor
|
| App Name | WordPress | |
| Configuration | Release-Alpha | |
| Build Number | 32272 | |
| Version | PR #25573 | |
| Bundle ID | org.wordpress.alpha | |
| Commit | d575c75 | |
| Installation URL | 4vo0q5s6fm0n8 |
Contributor
|
| App Name | Jetpack | |
| Configuration | Release-Alpha | |
| Build Number | 32272 | |
| Version | PR #25573 | |
| Bundle ID | com.jetpack.alpha | |
| Commit | d575c75 | |
| Installation URL | 1mndp1g162sp0 |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
crazytonyli
approved these changes
May 21, 2026
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
Enables the
explicit_initSwiftLint rule, which discourages writingType.init(...)whenType(...)is sufficient (the contextual init is enough).bundle exec rake lintfix.Part of the Orchard SwiftLint rollout campaign.
Testing instructions
CI: build + tests should remain green. The autofix is purely syntactic — it only removes the
.inittoken between a type and its argument list.