Skip to content

chore(#36): trial the ecosystem code-style policy - #37

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

chore(#36): trial the ecosystem code-style policy#37
gsdali merged 1 commit into
mainfrom
chore/36-code-style-ci

Conversation

@gsdali

@gsdali gsdali commented Aug 12, 2026

Copy link
Copy Markdown
Collaborator

What & why

Pilot repo for the ecosystem's proposed code-style policy
(ecosystem docs/code-style-policy-proposal-2026-08.md),
following the reference rollout at
OCCTSwiftScripts#114 /
#115. This repo is small (24 Swift
files, ~2,459 lines), so a full sweep rather than a gradual exemption manifest: bring the whole
tree into compliance in one PR and go straight to a blocking gate.

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, scoped to only_rules: [orphaned_doc_comment], same rationale as the reference
    repo: SwiftLint's defaults duplicate swift-format's formatting opinions and open a separate
    code-quality/complexity surface that belongs to the ecosystem's own code-structure policy, not
    this one.
  • Scripts/comment-ratio-check.sh: report-only nudge (never fails). This bootstraps the repo's
    first Scripts/ directory.
  • .github/workflows/code-style.yml: swift-format lint --strict and swiftlint lint --strict
    as blocking gates, comment-ratio as a non-blocking step. This bootstraps the repo's first CI
    workflow; there was no GitHub Actions setup here before this PR.
  • okf/policies/code-style.md, linked from okf/index.md, matching this repo's existing
    frontmatter conventions.
  • 38 by-hand fixes for lint-only findings swift-format --in-place can't auto-fix:
    • BeginDocumentationCommentWithOneLineSummary (28 doc comments): split into a one-sentence
      summary, a blank /// line, then the detail, across Mesh.swift (x4), GLTFAdapter.swift,
      MeshIO.swift (x2), OBJ.swift, STL.swift, PLY.swift, ThreeMFAdapter.swift (x3),
      CADBodyMetadata.swift, DXFLoader.swift (x3), ShapeLoader.swift (x7), and four Tests
      files.
    • EndOfLineComment (4): trailing comments that pushed the line past the column limit,
      moved to their own line above (GLTFAdapter.swift, MeshIO.swift, DXFLoader.swift,
      DXFLoaderTests.swift).
    • AlwaysUseLowerCamelCase (4 declarations, local-only): export_ renamed to exported
      everywhere it appeared, one declaration in MLExport.swift and three separate local
      declarations across MLExportTests.swift's test functions, each updated in place.
    • Two "terminate this sentence with a period" fixes (DXFLoaderTests.swift,
      JWWLoaderTests.swift): a trailing parenthetical restructured so the doc comment's last
      character is a period, not a closing paren.

Also clears every em-dash from every file this sweep touches, per this repo's own
writing-style policy ("clear them from any file you are already
editing"). One deliberate exception: Sources/MeshIO/OBJ.swift's exported-file header comment
("# MeshIO OBJ ...") is left as-is, since it's a string literal written into the output file
(runtime content, not source-level prose), and changing it would be a behavior change outside this
PR's scope.

Explicitly out of scope here (matching the pilot repo's precedent): clang-format, this repo
carries zero first-party C++ bridge files, confirmed before starting.

Zero behavior change. All changes are formatting, doc-comment structure, or a local-only
rename; verified directly, not just asserted:

  • swift-format lint --strict and swiftlint lint --strict: zero violations, both before commit.
  • Scripts/comment-ratio-check.sh: runs clean (2 files flagged above the 1.0x nudge threshold,
    CADBodyMetadata.swift and ImportProgressClosure.swift; report-only, does not fail).
  • swift build: succeeds identically before and after the sweep.
  • OCCT_SERIAL=1 swift test --parallel --num-workers 1: 41/41 tests pass, same suite, same
    count, both before and after the sweep.
  • No Package.resolved drift from any local build/test run.

Closes #36

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/doc-comments/CI only, one local-only rename),
    verified via the existing test suite (41/41 pass, identical before/after) rather than new
    tests, since there's no new behavior for a new test to cover.

Notes for the reviewer

Per the ecosystem's own gate (no repo implements without a filed issue first), this was filed as
#36 before any of this landed. Holding for review before merge, per the same process
OCCTSwiftScripts#115 followed.

Separately: this repo's okf/index.md currently links 4 of the ecosystem's 6 current mandatory
policies (missing issue-tracking and code-structure). Not addressed in this PR, out of scope
for a code-style rollout; flagging in case it is worth its own issue.

🤖 Generated with Claude Code

Pilot repo for the ecosystem's code-style policy proposal, following the reference
rollout at OCCTSwiftScripts#114/#115. This repo is small (24 Swift files, ~2,459
lines), so a full sweep rather than a gradual exemption manifest: sweep the whole
tree into compliance in one PR and turn on zero-tolerance blocking CI immediately.

- .swift-format: 100 col, 4-space (the ecosystem's one deliberate divergence from
  Google's 2-space default), copied verbatim from OCCTSwiftScripts.
- .swiftlint.yml: scoped to orphaned_doc_comment only via only_rules, not the
  default set, same rationale as the reference repo.
- Scripts/comment-ratio-check.sh: report-only nudge, never fails. Bootstraps this
  repo's first Scripts/ dir.
- .github/workflows/code-style.yml: swift-format lint --strict and swiftlint lint
  --strict as blocking gates, comment-ratio as a non-blocking step. Bootstraps
  this repo's first CI workflow (none existed before).
- okf/policies/code-style.md, linked from okf/index.md, matching this repo's
  existing frontmatter conventions.
- Full Sources/+Tests/ sweep via swift-format --in-place, plus by-hand fixes for
  the lint-only findings swift-format --in-place can't auto-fix:
  - BeginDocumentationCommentWithOneLineSummary: 26 doc comments split into a
    one-sentence summary + blank line + detail, across Mesh.swift, GLTFAdapter.swift,
    MeshIO.swift, OBJ.swift, STL.swift, PLY.swift, ThreeMFAdapter.swift,
    CADBodyMetadata.swift, DXFLoader.swift (x3), ShapeLoader.swift (x6), and four
    Tests files.
  - EndOfLineComment: 3 over-length trailing comments moved to their own line
    (GLTFAdapter.swift, MeshIO.swift, DXFLoader.swift), plus 1 in a test file.
  - AlwaysUseLowerCamelCase: local `export_` renamed to `exported` in
    MLExport.swift and all 4 call sites in MLExportTests.swift (local-only).
  - Two "terminate this sentence with a period" fixes (DXFLoaderTests.swift,
    JWWLoaderTests.swift): trailing parenthetical restructured so the doc
    comment ends on a period, not a closing paren.

Also clears every em-dash from every file this sweep touches, per this repo's
own writing-style policy ("clear them from any file you are already editing").
Left one string literal alone (Sources/MeshIO/OBJ.swift's exported-file header
comment) since it's runtime output content, not source-level prose, and
changing it would be a behavior change outside this PR's scope.

Verified locally, before and after the sweep:
- swift-format lint --strict, swiftlint lint --strict, comment-ratio-check.sh
  all pass (zero violations from both linters).
- swift build succeeds identically before and after.
- OCCT_SERIAL=1 swift test --parallel --num-workers 1: 41/41 tests pass, both
  before and after the sweep, same suite, same count.

Filed per the ecosystem's own gate: no repo implements without a filed issue
first. Closes #36.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@gsdali
gsdali merged commit 1145764 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.

Trial code-style policy CI: swift-format + SwiftLint + comment-ratio check

1 participant