Skip to content

Enable SwiftLint rule: untyped_error_in_catch#25571

Open
mokagio wants to merge 1 commit into
trunkfrom
mokagio/swiftlint-untyped-error-in-catch
Open

Enable SwiftLint rule: untyped_error_in_catch#25571
mokagio wants to merge 1 commit into
trunkfrom
mokagio/swiftlint-untyped-error-in-catch

Conversation

@mokagio
Copy link
Copy Markdown
Contributor

@mokagio mokagio commented May 20, 2026

Enables the untyped_error_in_catch SwiftLint rule, which flags catch let <name> patterns where the binding doesn't add a type cast — the implicit error constant is enough.

  • Auto-fixed: 20 violations across 16 files via bundle exec rake lintfix.
  • Agentic fixes: none.
  • Left for human review: none.

Part of the Orchard SwiftLint rollout campaign.

`bundle exec rake lintfix` autofixed 20 `catch let error` sites
across 16 files by dropping the explicit binding in favour of the
implicit `error` constant.

Part of the Orchard SwiftLint rollout campaign.

---

Generated with the help of Claude Code, https://claude.ai/code

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@mokagio mokagio requested a review from a team as a code owner May 20, 2026 12:45
Copilot AI review requested due to automatic review settings May 20, 2026 12:45
@mokagio mokagio self-assigned this May 20, 2026
@mokagio mokagio added this to the 26.9 milestone May 20, 2026
@dangermattic
Copy link
Copy Markdown
Collaborator

1 Warning
⚠️ This PR is assigned to the milestone 26.9. This milestone is due in less than 4 days.
Please make sure to get it merged by then or assign it to a milestone with a later deadline.

Generated by 🚫 Danger

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR enables SwiftLint’s untyped_error_in_catch rule and applies automated fixes to remove redundant catch let <name> bindings where no type-cast is performed.

Changes:

  • Enabled untyped_error_in_catch in .swiftlint.yml.
  • Replaced redundant catch let … patterns with catch across multiple Swift files.

Reviewed changes

Copilot reviewed 17 out of 17 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
WordPress/WordPressScreenshotGeneration/SnapshotHelper.swift Removes redundant catch bindings during snapshot setup and screenshot write.
WordPress/Classes/ViewRelated/Reader/Controllers/ReaderPostActions/ReaderBlockUserAction.swift Simplifies catch blocks for account lookup and save failures.
WordPress/Classes/ViewRelated/NUX/Controllers/Social Signup/SignupEpilogueViewController.swift Updates catch syntax in password change flow (but currently introduces an undefined identifier).
WordPress/Classes/ViewRelated/Me/Me Main/MeViewController.swift Simplifies catch syntax in async refresh flow.
WordPress/Classes/ViewRelated/Me/App Settings/EncryptedLogTableViewController.swift Updates catch syntax when enqueueing encrypted logs (but currently introduces an undefined identifier).
WordPress/Classes/Utility/ZendeskUtils.swift Updates catch syntax in encrypted log UUID helper (but currently introduces an undefined identifier).
WordPress/Classes/Utility/BackgroundTasks/WeeklyRoundupBackgroundTask.swift Simplifies catch syntax when building stats service.
WordPress/Classes/Services/ReaderPostStreamService.swift Simplifies catch syntax during Core Data cleanup.
WordPress/Classes/Services/ReaderCardService.swift Simplifies catch syntax during Core Data cleanup.
WordPress/Classes/Jetpack/JetpackMigration/Common/MigrationEmailService.swift Simplifies catch syntax across init/send/decode code paths.
Sources/WordPressData/Swift/BlockedSite.swift Simplifies catch syntax in fetch helper.
Sources/WordPressData/Swift/BlockedAuthor.swift Simplifies catch syntax in fetch helper.
Modules/Sources/WordPressKit/SiteDesignServiceRemote.swift Simplifies catch syntax in response parsing.
Modules/Sources/WordPressKit/PlanServiceRemote_ApiVersion1_3.swift Simplifies catch syntax in plan parsing.
Modules/Sources/WordPressKit/FeatureFlagRemote.swift Simplifies catch syntax for parameter serialization errors.
Modules/Sources/WordPressKit/DomainsServiceRemote+AllDomains.swift Simplifies catch syntax for query parameter construction errors.
.swiftlint.yml Enables the untyped_error_in_catch rule.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

}
} catch let err {
} catch {
finished(false, err)
}
catch let err {
catch {
let alert = UIAlertController(title: "Unable to create log", message: err.localizedDescription, preferredStyle: .actionSheet)
}
catch let err {
catch {
return "Error preparing log file: \(err.localizedDescription)"
@wpmobilebot
Copy link
Copy Markdown
Contributor

🤖 Build Failure Analysis

This build has failures. Claude has analyzed them - check the build annotations for details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants