Skip to content

chore(#42): roll out ecosystem code-style policy - #43

Merged
gsdali merged 1 commit into
mainfrom
chore/42-code-style-sweep
Aug 12, 2026
Merged

chore(#42): roll out ecosystem code-style policy#43
gsdali merged 1 commit into
mainfrom
chore/42-code-style-sweep

Conversation

@gsdali

@gsdali gsdali commented Aug 12, 2026

Copy link
Copy Markdown
Collaborator

What & why

Rolls out the ecosystem's code-style policy to this repo
(ecosystem docs/code-style-policy-proposal-2026-08.md),
following OCCTSwiftScripts#114 /
#115 as the reference implementation
for a repo this size: a full sweep into compliance in one PR and straight to a blocking gate, not
OCCTSwift's gradual "if you touch it, you fix it" exemption manifest (that pattern is for large
repos, not this one). This repo is ~6.6k lines across 30 files, small enough to fully sweep.

Adds:

  • .swift-format (100 col, 4-space, the ecosystem's one deliberate divergence from Google's
    2-space default) copied verbatim from OCCTSwiftScripts, plus a full swift-format --in-place
    sweep of Sources/+Tests/.
  • .swiftlint.yml, deliberately narrow (only_rules: [orphaned_doc_comment]). SwiftLint's
    default rule set duplicates swift-format's formatting opinions (can disagree with them on the
    same line) and separately opens a large code-quality/complexity surface that overlaps the
    ecosystem's own code-structure policy rather than this one. Scoped down to the one rule that
    catches something swift-format has no equivalent for.
  • Scripts/comment-ratio-check.sh: report-only nudge (never fails), bash variant matching
    OCCTSwiftScripts' own convention (not the Python style OCCTSwift/Scripts/ uses).
  • .github/workflows/code-style.yml: swift-format lint --strict and swiftlint lint --strict
    as blocking gates, comment-ratio as a non-blocking step. This repo had no CI at all before
    this PR, so this bootstraps it from nothing.
  • okf/policies/code-style.md: this repo's 7th policy, linked from okf/index.md.
  • Zero first-party C++ bridge files in this repo (confirmed), so clang-format is out of scope,
    same as noted in the tracking issue.

Hand-fixed lint findings (62 total, everything swift-format --in-place couldn't auto-fix)

  • 57× BeginDocumentationCommentWithOneLineSummary. Split a doc comment's first sentence from
    its body with a blank /// line, per Google's style guide structure. One genuine swift-format
    quirk found and worked around: a backtick code span immediately followed by a bare 's
    (e.g. `DragGesture`'s) makes the sentence-boundary parser misreport "doesn't terminate with
    a period" even when it does; the fix is moving the possessive inside the span
    (`DragGesture's`), verified empirically against isolated repro cases before applying it
    across every occurrence.
  • orphaned_doc_comment (StandardObjects.swift): a file-level summary comment sat before
    // MARK: - Trihedron and Trihedron's own (separately documented) doc comment, describing all
    four types in the file, not just Trihedron. Demoted /// to // since it's file-scoped
    commentary, not documentation of one following declaration, and it doesn't duplicate anything
    already documented.
  • AlwaysUseLowerCamelCase (ManipulatorWidget.swift, local to updateRotateDrag):
    R -> rotation, M -> rotateAboutPivot. Local-only, all call sites in the same function
    updated, no public API change.
  • EndOfLineComment: moved a trailing // comment that exceeded the line length onto its
    own line above, in SelectionFilterTests.swift (x2) and ManipulatorRotateTests.swift.

Em-dash cleanup

The ecosystem's writing-style policy requires clearing em-dashes "from any file you are already
editing," not only new ones. Every file swift-format --in-place or a hand-fix touched carried
pre-existing em-dashes in doc/line comments (101 occurrences across 26 files); all replaced with
ordinary punctuation (comma, colon, semicolon, or a split sentence), preserving meaning. Also
caught and fixed two misattributed pieces of copied text: the comment-ratio script's header cited
OCCTSwiftScripts#114 (now points at this repo's own #42, crediting #114/#115 as the
reference), and .swiftlint.yml's rationale comment cited OCCTSwiftScripts' own 548 hits measurement
for identifier_name as if it were this repo's number (now attributed correctly).

Verification

Zero behavior change. Formatting, doc comments, and two local-only renames only; no public API,
signature, or logic changed.

  • swift-format lint --strict (Sources/+Tests/): 0 violations (was 532 pre-sweep).
  • swiftlint lint --strict: 0 violations, 0 serious (was 1: the orphaned_doc_comment above).
  • Scripts/comment-ratio-check.sh: no files at or above 1.0x comment:code (Sources/), exit 0.
  • swift build: succeeds before and after the sweep (Build complete!).
  • swift test: fails to compile both before and after the sweep, with the exact same two
    pre-existing, unrelated compile errors (confirmed via a clean-tree git stash baseline run
    before touching anything):
    • InteractiveContextMutationTests.swift / RemapTests.swift: value of optional type 'SIMD3<Double>?' must be unwrapped (centroids.enumerated().min { ... }?.offset needs a
      force-unwrap or optional chain) — 40 identical error occurrences in both runs.
    • RemapTests.swift: cannot infer contextual base in reference to member 'body' (.body(newObj)
      inside #expect(...)) — 4 identical error occurrences in both runs, just at a shifted line
      number post-sweep since earlier swift-format reflow moved the line down.
    • Not fixed here: pre-existing, unrelated to code style, out of scope for a formatting/docs pass.
      Flagging in case it's worth its own issue; happy to file one if wanted.
  • Package.resolved: untouched by this PR (verified no diff from local build/test runs).

Closes #42

Checklist

  • New or changed behavior is covered by a unit test in the same PR (not just manual
    verification) — see SecondMouseAU/OCCTReconstruct#397
    for the ecosystem-wide test-coverage standard this is piloting.
    — N/A here: no behavior changed (formatting/docs/CI only), verified via lint tool exit
    codes and the before/after build/test comparison above rather than new tests.

Notes for the reviewer

Per the ecosystem's own gate (no repo implements without a filed issue first), this was filed as
#42 before any of this landed. Holding for review, not to merge.

The pre-existing swift test compile failure (see Verification above) is real and reproducible on
a clean main checkout, unrelated to this change. Flagging rather than fixing, since it's out of
scope for a code-style/formatting PR and touching it would mix an unrelated fix into this diff.

🤖 Generated with Claude Code

Full sweep into compliance with the ecosystem's proposed code-style policy
(docs/code-style-policy-proposal-2026-08.md in the ecosystem repo), following
OCCTSwiftScripts#114/#115 as the reference implementation for a repo this
size: full sweep in one PR, straight to a blocking gate, not a gradual
exemption manifest.

Adds:
- .swift-format (100 col, 4-space) + a full swift-format --in-place sweep of
  Sources/ and Tests/.
- .swiftlint.yml, scoped to only_rules: [orphaned_doc_comment].
- Scripts/comment-ratio-check.sh: report-only nudge (never fails), bash
  variant matching OCCTSwiftScripts' own convention.
- .github/workflows/code-style.yml: swift-format lint --strict and swiftlint
  lint --strict as blocking gates, comment-ratio as non-blocking. This repo
  had no CI before this PR.
- okf/policies/code-style.md (7th policy for this repo), linked from
  okf/index.md.
- Hand fixes for every lint-only finding swift-format --in-place couldn't
  auto-fix: BeginDocumentationCommentWithOneLineSummary (blank-line-separated
  summary/body), one orphaned_doc_comment (file-level comment demoted from
  /// to //), two AlwaysUseLowerCamelCase renames (R/M -> rotation/
  rotateAboutPivot, local-only), three EndOfLineComment fixes.
- Em-dash cleanup across every file touched, per the ecosystem's writing-style
  policy ("clear them from any file you are already editing").

Zero behavior change: formatting, doc comments, and local-only renames only.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@gsdali
gsdali merged commit 6e1646c into main Aug 12, 2026
2 checks passed
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.

Roll out ecosystem code-style policy: swift-format + SwiftLint + comment-ratio check

1 participant