Skip to content

chore(tooling): add swiftformat lint to lefthook with relaxed baseline config (option b) - #149

Merged
wei18 merged 2 commits into
mainfrom
chore/swiftformat-config-option-b
May 26, 2026
Merged

wei18 merged 2 commits into
mainfrom
chore/swiftformat-config-option-b

Conversation

@wei18

@wei18 wei18 commented May 26, 2026

Copy link
Copy Markdown
Owner

Summary

User decision 2026-05-26: option (b) for swiftformat — write `.swiftformat` config that relaxes rules to match current code style, rather than (a) mass-format 204 files / (b) defer entirely.

Goal: baseline passes without touching any source; swiftformat catches NEW drift; future trigger to revisit option (a) when style review nits accumulate.

Changes

  • New .swiftformat — 32 rules disabled to match baseline:
    • 18 high-volume (≥ 12 violations each)
    • 14 long-tail (< 10 each)
    • Cosmetic rules like `duplicateImports` remain enforced (verified with intentional violation → exit 1)
  • lefthook.yml — append swiftformat command after swiftlint (sequential per fix(lefthook): serialize pre-commit to break RCA H4 mise deadlock #136)
  • docs/foundations.md §7.5.1 — document option (b) choice + re-evaluation trigger

4 files, +171 LOC. Zero source .swift files touched.

Baseline analysis — top 5 violated rules (default config)

Rule Violations
indent 669
redundantInternal 238
sortImports 199
hoistPatternLet 146
blankLinesAtStartOfScope 141

`--ifdef no-indent` alone resolves 653/669 indent violations (matches the `#if/#else` column-1 convention this repo uses).

Validation

  • `swiftformat --lint Packages/ App/` → `0/244 files require formatting` (exit 0)
  • Intentional violation test: triggered correctly, lefthook fails as expected
  • Lefthook total runtime 0.60s sequential (gitleaks 0.36 + hygiene 0.01 + swiftformat 0.04 + swiftlint 0.14)
  • `swift build` unchanged (zero source files touched)

Cross-PR coordination

PR #147 (GH Actions Phase 1) ships `lint.yml` with SwiftFormat step as `continue-on-error: true` pending this baseline. After this merges, flip `continue-on-error: false` in a follow-up commit so CI hard-fails on drift.

Closes

Test plan

  • Confirm `.swiftformat` rule list reads as expected
  • Confirm relaxation choices match observed style (skim diff)
  • After merge: flip `lint.yml` SwiftFormat to hard-fail in follow-up

🤖 Generated with Claude Code

wei18 and others added 2 commits May 26, 2026 13:32
Author a .swiftformat config that matches the existing codebase style
(option b — disable 18+14 rules currently violated en-masse, --ifdef
no-indent for column-1 #if convention) so all 244 source files pass
swiftformat --lint without mass-format churn (~3,624 LOC avoided).

Add swiftformat --lint to lefthook.yml pre-commit (report-only, after
swiftlint, sequential per parallel:false RCA H4). Future commits drift
into the baseline-relaxed style or fail locally.

Re-evaluation trigger and per-rule violation counts documented in
docs/foundations.md §7.5.1 and meetings/2026-05-26_swiftformat-option-b.impl-notes.md.
- N1: tighten --ifdef no-indent comment in .swiftformat — reflect reality
  that the repo mixes top-level col-1 directives with body-indent inner
  directives (UMPConsentPresenter.swift has both forms). Prior comment
  was misleading.
- N2: reconcile indent violation count between .swiftformat (669) and
  docs/foundations.md §7.5.1 (was 685). 669 matches the swiftformat
  --lint baseline output the implementer subagent captured.
- N4: add lockstep note to docs/foundations.md §7.5.1 — bumping
  swift-tools-version in Package.swift requires bumping the
  --swiftversion 6.2 pin in .swiftformat.

N3 (lint.yml flip to hard-fail after this merges) tracked in PR body
as post-merge action, not in this commit.

Co-Authored-By: Claude Opus 4.7 <[email protected]>
@wei18

wei18 commented May 26, 2026

Copy link
Copy Markdown
Owner Author

CR nits applied (commit 81977bd)

3 of 4 nits inline-fixed:

  • N1 ✅ --ifdef no-indent comment in .swiftformat tightened — reflects reality of mixed top-level col-1 + body-indent directives
  • N2 ✅ indent count reconciled 685 → 669 in docs/foundations.md §7.5.1
  • N4 ✅ lockstep note added — bumping Package.swift swift-tools-version requires bumping .swiftformat --swiftversion pin in lockstep
  • N3 ⏭️ post-merge action (intentionally not in this commit): after this lands, flip .github/workflows/lint.yml SwiftFormat step from continue-on-error: true to hard-fail per its own inline TODO

CR praise

Ready to merge.

@wei18
wei18 merged commit 0c699fd into main May 26, 2026
2 of 3 checks passed
@wei18
wei18 deleted the chore/swiftformat-config-option-b branch May 26, 2026 06:14
wei18 added a commit that referenced this pull request May 26, 2026
…ollow-up) (#151)

PR #149 landed `.swiftformat` option (b) relaxed-baseline config.
244/244 files now compliant with the pinned ruleset, so the advisory
`continue-on-error: true` guard from PR #147 is no longer needed.

Removes the guard + updates the inline comment to reference the new
state + escape hatch for future broad-violations regressions.

Co-authored-by: Claude Opus 4.7 <[email protected]>
wei18 added a commit that referenced this pull request May 26, 2026
…scriptions

Inline-applied from CR review of PR #152:

- pr-diff-verification: drop fabricated PR #126 narrative; replace
  with generic pattern description covering 3 recurring failure modes
- monetization-sdk-integration:
  - fix FakeAdMobBridge path (Tests/AdsAdMobTests/, not MonetizationTesting/)
  - drop wrong PR #149 attribution (it's swiftformat, not the fatalError)
  - clarify Sources/MonetizationTesting/ scaffolding vs test-target fakes
  - tighten description for clearer auto-discovery trigger (CR B+ → A)
- subagent-conflict-detection: §派發契約 §9 → "item 9"
  (methodology uses narrative numbering, not formal §N sub-headings)

No content removed — only factual corrections + 1 description tighten.

Co-Authored-By: Claude Opus 4.7 <[email protected]>
wei18 added a commit that referenced this pull request May 26, 2026
…tem) (#152)

* docs(skills): fill 4 repo-derived skills + foundations.md update (closes #11 5-of-5)

Closes the "補齊 repo skills/context 缺口" backlog entry from 2026-05-24
reflection. All 5 sub-items now landed:

(a) ✅ subagent-conflict-detection — pre-dispatch grep target file set
    vs in-flight subagent worktrees; prevents parallel-dispatch race
(b) ✅ pr-diff-verification — pre-push `git show --stat HEAD` cross-check
    vs commit message claims; encodes PR #126 incident + worktree-wipe
    lost-commits + push-wrong-ref footguns
(c) ✅ asc-ops-handoff — User-owned vs Leader-orderable vs hybrid
    taxonomy for App Store Connect / TestFlight / Apple Developer ops;
    references canonical docs (v2.5-readiness.md, ASCRegister, etc.)
(d) ✅ monetization-sdk-integration — foundations §9 break-glass
    exception process + isolation contract (single-file protocol seam,
    canImport gating, audit grep regex); encodes AdMob v13 upgrade +
    Production ID swap safety + macOS conditional gating incidents
(e) ✅ memory subdir reorg — already in place since 2026-05-25
    (user/feedback/project/reference dirs)

All 4 new skills live at `.claude/skills/<name>/SKILL.md` per
[[feedback-project-derived-skills-location]] (project-derived skills
are repo-level, not $HOME).

foundations.md §Backlog entry updated with ✅ marks + linked file refs.

Co-Authored-By: Claude Opus 4.7 <[email protected]>

* docs(skills): apply CR #152 nits — fix factual citations + tighten descriptions

Inline-applied from CR review of PR #152:

- pr-diff-verification: drop fabricated PR #126 narrative; replace
  with generic pattern description covering 3 recurring failure modes
- monetization-sdk-integration:
  - fix FakeAdMobBridge path (Tests/AdsAdMobTests/, not MonetizationTesting/)
  - drop wrong PR #149 attribution (it's swiftformat, not the fatalError)
  - clarify Sources/MonetizationTesting/ scaffolding vs test-target fakes
  - tighten description for clearer auto-discovery trigger (CR B+ → A)
- subagent-conflict-detection: §派發契約 §9 → "item 9"
  (methodology uses narrative numbering, not formal §N sub-headings)

No content removed — only factual corrections + 1 description tighten.

Co-Authored-By: Claude Opus 4.7 <[email protected]>

---------

Co-authored-by: Claude Opus 4.7 <[email protected]>
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.

1 participant