Skip to content

Enable SwiftLint rule: contains_over_first_not_nil#25523

Draft
mokagio wants to merge 1 commit intotrunkfrom
mokagio/swiftlint-contains-over-first-not-nil
Draft

Enable SwiftLint rule: contains_over_first_not_nil#25523
mokagio wants to merge 1 commit intotrunkfrom
mokagio/swiftlint-contains-over-first-not-nil

Conversation

@mokagio
Copy link
Copy Markdown
Contributor

@mokagio mokagio commented May 4, 2026

Summary

Enables SwiftLint's contains_over_first_not_nil rule and rewrites the 13 existing violations.

The rule prefers xs.contains { ... } over xs.first(where: { ... }) != nil (and the firstIndex variant), which is a performance and clarity win.

  • 13 violations fixed across 9 files.
  • 0 suppressions.
  • Some inverted forms (first { } == nil) were rewritten with !contains / allSatisfy depending on what reads cleanest.
  • The rewrite is type-preserving (Bool→Bool) — local build deferred to CI.

Part of the Orchard SwiftLint rollout campaign.

Test plan

  • CI build is green.
  • swiftlint lint --strict --no-cache is clean against the rule.

🤖 Generated with Claude Code

Adds the rule to `only_rules` and rewrites the 13 existing violations:

- `xs.first(where: { ... }) != nil` → `xs.contains(where: { ... })`
- `xs.first { ... } == nil` patterns rewritten using the equivalent
  `!contains` / `allSatisfy` form, depending on what reads cleanest.

The rewrite is type-preserving (Bool→Bool) — local build deferred to CI.

Part of the Orchard SwiftLint rollout campaign.

---

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

Co-Authored-By: Claude Code Opus 4.7 <noreply@anthropic.com>
@mokagio mokagio self-assigned this May 4, 2026
@mokagio mokagio added this to the 26.9 milestone May 4, 2026
@dangermattic
Copy link
Copy Markdown
Collaborator

1 Message
📖 This PR is still a Draft: some checks will be skipped.

Generated by 🚫 Danger

@wpmobilebot
Copy link
Copy Markdown
Contributor

App Icon📲 You can test the changes from this Pull Request in WordPress by scanning the QR code below to install the corresponding build.
App NameWordPress
ConfigurationRelease-Alpha
Build Number32099
VersionPR #25523
Bundle IDorg.wordpress.alpha
Commit86157be
Installation URL77jeinuoimd60
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

@wpmobilebot
Copy link
Copy Markdown
Contributor

App Icon📲 You can test the changes from this Pull Request in Jetpack by scanning the QR code below to install the corresponding build.
App NameJetpack
ConfigurationRelease-Alpha
Build Number32099
VersionPR #25523
Bundle IDcom.jetpack.alpha
Commit86157be
Installation URL0nqsd7tkl6tjg
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

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.

3 participants