Skip to content

Conversation

@mildm8nnered
Copy link
Collaborator

No description provided.

@mildm8nnered mildm8nnered requested a review from Copilot October 17, 2025 10:46
@SwiftLintBot
Copy link

SwiftLintBot commented Oct 17, 2025

1 Warning
⚠️ If this is a user-facing change, please include a CHANGELOG entry to credit yourself!
You can find it at CHANGELOG.md.
18 Messages
📖 Building this branch resulted in the same binary size as when built on main.
📖 Linting Aerial with this PR took 0.82 s vs 0.82 s on main (0% slower).
📖 Linting Alamofire with this PR took 1.03 s vs 1.06 s on main (2% faster).
📖 Linting Brave with this PR took 6.85 s vs 6.87 s on main (0% faster).
📖 Linting DuckDuckGo with this PR took 21.9 s vs 22.0 s on main (0% faster).
📖 Linting Firefox with this PR took 10.85 s vs 10.82 s on main (0% slower).
📖 Linting Kickstarter with this PR took 7.63 s vs 7.6 s on main (0% slower).
📖 Linting Moya with this PR took 0.42 s vs 0.46 s on main (8% faster).
📖 Linting NetNewsWire with this PR took 2.4 s vs 2.39 s on main (0% slower).
📖 Linting Nimble with this PR took 0.64 s vs 0.63 s on main (1% slower).
📖 Linting PocketCasts with this PR took 6.79 s vs 6.83 s on main (0% faster).
📖 Linting Quick with this PR took 0.4 s vs 0.39 s on main (2% slower).
📖 Linting Realm with this PR took 3.29 s vs 3.31 s on main (0% faster).
📖 Linting Sourcery with this PR took 1.87 s vs 1.88 s on main (0% faster).
📖 Linting Swift with this PR took 4.2 s vs 4.22 s on main (0% faster).
📖 Linting VLC with this PR took 1.15 s vs 1.12 s on main (2% slower).
📖 Linting Wire with this PR took 17.35 s vs 17.38 s on main (0% faster).
📖 Linting WordPress with this PR took 11.46 s vs 11.5 s on main (0% faster).

Here's an example of your CHANGELOG entry:

* Add some more rule rationales.  
  [mildm8nnered](https://github.com/mildm8nnered)
  [#issue_number](https://github.com/realm/SwiftLint/issues/issue_number)

note: There are two invisible spaces after the entry's text.

Generated by 🚫 Danger

Copy link

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 adds rationale documentation to several SwiftLint rules, explaining why certain coding patterns are preferred over others. The rationales primarily focus on performance benefits and API modernization.

Key Changes

  • Added performance-related rationales to five rules that recommend using more efficient alternatives
  • Added API modernization rationale to the legacy NSGeometry functions rule

Reviewed Changes

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

Show a summary per file
File Description
EmptyCountRule.swift Added rationale explaining O(1) vs O(n) performance difference between isEmpty and count
ContainsOverRangeNilComparisonRule.swift Added rationale explaining early exit benefits of contains over range(of:)
ContainsOverFirstNotNilRule.swift Added rationale explaining early exit benefits of contains over first(where:)
ContainsOverFilterIsEmptyRule.swift Added rationale explaining early exit benefits of contains over filter
ContainsOverFilterCountRule.swift Added rationale explaining early exit benefits of contains over filter
LegacyNSGeometryFunctionsRule.swift Added rationale explaining modern API benefits and cross-platform support

Comment on lines +12 to +13
`filter` always needs to scan the entire collection, whereas `contains` can exit early as
soon as a match is found.
Copy link

Copilot AI Oct 17, 2025

Choose a reason for hiding this comment

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

The rationale incorrectly mentions filter when it should refer to first(where:) and firstIndex(where:). The rule is about these methods, not filter. Update the rationale to correctly explain that first(where:) and firstIndex(where:) already support early exit, but using contains is more semantically clear when you only need to check for existence.

Suggested change
`filter` always needs to scan the entire collection, whereas `contains` can exit early as
soon as a match is found.
While `first(where:)` and `firstIndex(where:)` already support early exit, using `contains` is more semantically clear when you only need to check for the existence of an element matching a predicate.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants