Skip to content

feat(core): broaden .understandignore starter — Swift XCTest/Quick patterns #599

Description

@thejesh23

Problem

.understandignore starter has no Swift-specific suggestions. Impact splits by project shape:

  • SPM libraries (apple/swift, Alamofire, Vapor) already funnel all tests into Tests/ — caught by the case-insensitive tests dir rule. Little to gain.
  • Xcode consumer apps (stripe-ios, kickstarter/ios-oss, duckduckgo/iOS, firefox-ios) use <AppName>Tests/ folders that no leading-dot suffix rule reaches, plus a heavy tail of inline *Tests.swift files scattered across production modules. Large gain — measurement showed up to 34% reduction on stripe-ios.

Proposal

New Swift group under TEST_PATTERN_GROUPS:

  • **/*Tests.swift — dominant XCTest / Swift Testing convention
  • **/*Test.swift — singular variant seen in older codebases
  • **/*Spec.swift — Quick / Nimble BDD framework

All commented-out, opt-in. Same model as #76 / #479 / #578 / #581 / #596.

Deliberately not adding dir rules. Measurement across 20 Swift repos showed:

  • *tests/ case-insensitive dir suffix: adds only 1 pp on the weighted total (the file globs already catch the same files by a different path), while carrying real false-positive risk on unrelated PascalCase dirs (Contests/, Requests/, Interests/, Manifests/).
  • uitests exact rule: zero incremental hits — UI-test dirs' contents are already *UITests.swift, caught by the file glob.

Token impact (measured across 20 public Swift repos)

Methodology: gh api .../git/trees?recursive=1, Swift source = .swift, 1 MiB ≈ 262K tokens.

Project Before (analyzed) After (analyzed) Reduction
stripe/stripe-ios 14.29 MB / ~3.57M tok 9.47 MB / ~2.37M tok −1.20M (34%)
kickstarter/ios-oss 10.38 MB / ~2.59M tok 7.12 MB / ~1.78M tok −0.81M (31%)
  • stripe-ios — highest %, 605 file-glob hits. <Framework>Tests/ sub-projects (StripeIdentityTests, StripePaymentSheetTests) each contain hundreds of inline *Tests.swift files.
  • kickstarter/ios-oss — 461 file-glob hits. Layered project colocates Foo.swift + FooTests.swift throughout Library/, KsApi/.

Weighted total across the 10-repo Xcode-app subset (75 MB): −2.57M tok / 14%. Range across the full 20-repo sample: 0% (SPM libraries whose Tests/ is already caught) to 34% (Xcode consumer apps).

Why Swift, why these patterns

Consumer iOS apps are where these patterns earn their weight. SPM libraries incur zero behaviour change under the opt-in model. This is the same "layout the existing rules miss" story that showed up for C++ (nlohmann/json 62% in #480), Ruby (rubocop 67% in #597), Python (tensorflow 47% in #579), and Rust (parity-common 28% in #582).

Out of scope

  • <AppName>Tests/ / <AppName>UITests/ Xcode dir handling (measurement rejected — marginal 1 pp with false-positive risk).
  • Mock/stub file patterns (*Mock.swift, Fake*.swift) — potential follow-up if false-positive risk can be controlled.
  • PHP / Dart / C / Lua groups — follow-ups tracked separately.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions