Enable SwiftLint rule: redundant_nil_coalescing#25533
Conversation
Generated by 🚫 Danger |
🤖 Build Failure AnalysisThis build has failures. Claude has analyzed them - check the build annotations for details. |
|
Version |
9e50779 to
84f793d
Compare
The `redundant_nil_coalescing` rule enabled in 356eaa5 treats `?? nil` as syntactically redundant regardless of whether the LHS is `T?` (truly redundant) or `T??` (essential flatten). Four sites were flattening `T??` and stopped compiling once the rule autofix removed them. Switch each to a form the rule doesn't trip: - `Dictionary[key, default: nil]` on `[K: V?]` returns `V?` directly, avoiding the `T??` intermediate from a raw subscript. - A `do`/`catch` around `decodeIfPresent` in `JetpackScanThreat` preserves "treat malformed value as absent" semantics without producing the `T??` that `try?` over a throwing `T?` would. `bundle exec fastlane ios test` passes (3415 tests, 0 failures). --- Generated with the help of Claude Code, https://claude.ai/code Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
84f793d to
09850ba
Compare
|
| App Name | Jetpack | |
| Configuration | Release-Alpha | |
| Build Number | 32347 | |
| Version | PR #25533 | |
| Bundle ID | com.jetpack.alpha | |
| Commit | 09850ba | |
| Installation URL | 14nc8944j1o38 |
|
| App Name | WordPress | |
| Configuration | Release-Alpha | |
| Build Number | 32347 | |
| Version | PR #25533 | |
| Bundle ID | org.wordpress.alpha | |
| Commit | 09850ba | |
| Installation URL | 7tpmtroltr60o |
There was a problem hiding this comment.
Pull request overview
Enables the SwiftLint redundant_nil_coalescing opt-in rule and applies its auto-fixes across the codebase, removing ?? nil expressions that operate on already-optional values. For dictionary lookups where values are themselves optional (producing nested optionals), the fix switches to subscript(_:default:) with a nil default to preserve the single-optional result type. A semantic-equivalent rewrite of try? ... ?? nil to an explicit do/catch in JetpackScanThreat preserves the prior failure-to-nil behavior.
Changes:
- Add
redundant_nil_coalescingto.swiftlint.yml'sonly_rules. - Apply
swiftlint --fixautofixes removing redundant?? nilacross app, modules, and tests. - Convert a
try? ... ?? nildecode inJetpackScanThreatto an explicitdo/catchand switch optional-valued dictionary reads tosubscript(_:default: nil).
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| .swiftlint.yml | Opt in to the new redundant_nil_coalescing rule. |
| WordPress/Classes/ViewRelated/Support/SupportTableViewController.swift | Drop redundant ?? nil after optional chain. |
| WordPress/Classes/ViewRelated/Reader/Manage/OffsetTableViewHandler.swift | Drop redundant ?? nil after Optional.map. |
| WordPress/Classes/ViewRelated/Reader/Detail/Views/ReaderDetailHeaderView.swift | Drop redundant ?? nil from avatarURLForDisplay() assignment. |
| WordPress/Classes/ViewRelated/Jetpack/Jetpack Scan/JetpackScanCoordinator.swift | Drop redundant ?? nil after optional chain. |
| WordPress/Classes/Stores/StatsPeriodStore.swift | Switch nested-optional dictionary read to subscript(_:default: nil). |
| Tests/WordPressKitTests/WordPressKitTests/Tests/MediaLibraryTestSupport.swift | Drop redundant ?? nil from optional helper call. |
| Tests/KeystoneTests/Tests/Features/Domains/RegisterDomainDetailsViewModelTests.swift | Drop redundant ?? nil from optional casts. |
| Sources/WordPressData/Swift/SiteTaxonomy.swift | Switch optional-valued label reads to subscript(_:default: nil). |
| Modules/Sources/WordPressKitModels/RemoteUser+Likes.swift | Drop redundant ?? nil from optional cast. |
| Modules/Sources/WordPressKit/JetpackScanThreat.swift | Replace try? ... ?? nil with explicit do/catch for fixable. |
| Modules/Sources/WordPressKit/DomainsServiceRemote.swift | Drop redundant ?? nil from optional casts. |
| Modules/Sources/AsyncImageKit/Helpers/ImageSaliencyService.swift | Switch nested-optional cache read to subscript(_:default: nil). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.


Summary
Enables SwiftLint's
redundant_nil_coalescingrule.The rule flags
?? <default>applied to a non-optional value, which is redundant — the right-hand side can never be reached.swiftlint --fix.Part of the Orchard SwiftLint rollout campaign.
Test plan
swiftlint lint --strict --no-cacheis clean against the rule.🤖 Generated with Claude Code