Skip to content

chore(#53): roll out the ecosystem code-style policy - #54

Merged
gsdali merged 1 commit into
mainfrom
chore/code-style-policy-issue-53
Aug 12, 2026
Merged

chore(#53): roll out the ecosystem code-style policy#54
gsdali merged 1 commit into
mainfrom
chore/code-style-policy-issue-53

Conversation

@gsdali

@gsdali gsdali commented Aug 12, 2026

Copy link
Copy Markdown
Collaborator

What & why

Rolls out the ecosystem's code-style policy
(ecosystem docs/code-style-policy-proposal-2026-08.md),
following OCCTSwiftScripts#114 /
#115 as the reference
implementation for a repo this size: full sweep, not a gradual exemption manifest. This repo is
small (~2,280 Swift lines across ~19 files, all pure Swift, zero first-party C++ bridge files
despite "bridge" being in the repo's own description), small enough to sweep into full 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, deliberately narrow (only_rules: [orphaned_doc_comment]), also copied from
    OCCTSwiftScripts' pattern. 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 (identifier_name, cyclomatic_complexity,
    function_body_length, nesting, ...) that overlaps the ecosystem's own code-structure
    policy rather than this one; identifier_name's default alone produced 149 hits measured fresh
    for this repo (not carried over from OCCTSwiftScripts' own number), all short conventional
    locals (i, p, n, db) in dense numerical/graph code, none real problems. 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), matching OCCTSwiftScripts'
    own bash-script convention. This repo had no Scripts/ directory before; this bootstraps one.
  • .github/workflows/code-style.yml: swift-format lint --strict and swiftlint lint --strict
    as blocking gates, comment-ratio as a non-blocking step. Pure text analysis, no swift build
    needed. This repo had no CI before; this bootstraps CI from nothing.
  • okf/policies/code-style.md: this repo's 7th mandatory policy, linked from okf/index.md
    (this repo's bundle: context-first, docs-current, writing-style, search-before-building,
    code-structure, issue-tracking, and now code-style).
  • Hand-fixes for the lint-only findings neither tool auto-fixes, the same categories
    OCCTSwiftScripts#115 hit:
    • BeginDocumentationCommentWithOneLineSummary: a blank /// line added after the
      one-sentence summary in ~14 doc comments across CADFileLoader.swift,
      FaceIdentityTable.swift, EdgeIdentityTable.swift, VertexIdentityTable.swift, and one
      test file.
    • ValidateDocumentationComments: Returns: sections added to PointConverter.pointsToBody,
      BodyUtilities.makeMarkerSphere, SurfaceConverter.surfaceToGridBodies,
      WireConverter.wireToBody, and CADFileLoader.shapeToBodyAndMetadata; a Throws: section
      added to CADFileLoader.load; four singular - Parameter x: blocks converted to plural
      - Parameters: blocks (CADFileLoader.load, CADFileLoader.shapeToBodyAndMetadata,
      WireConverter.wireToBody), which surfaced that the plural form is validated for
      completeness against the full parameter list, by internal name where it differs from the
      external label (bodyID/rgba/customDeflection/useDirectMesh, not
      id/color/deflection/directMesh), not just the params that already had prose.
    • No AlwaysUseLowerCamelCase or EndOfLineComment findings this pass, and no
      orphaned_doc_comment findings from SwiftLint either.
  • Incidental: cleared every em-dash found in every file touched by this sweep (source, tests, the
    new scaffold files, and the one pre-existing em-dash in okf/index.md's frontmatter
    description), per the ecosystem's writing-style policy's own "clear them from any file you are
    already editing" instruction.

Explicitly out of scope here (see the issue): clang-format (no first-party C++ in this
repo), and the Swift-symbol docs-drift checks proposed for OCCTSwift, tracked separately if this
repo's docs/reference/ (which documents Swift declarations directly, unlike OCCTSwiftScripts'
CLI-verb docs) turns out to need them.

Zero behavior change. Every change is a doc comment, a formatting pass, or CI/policy
scaffolding; no function signature or logic changed. Verified directly, not just asserted:

  • swift-format lint --strict and swiftlint lint --strict both report zero violations
    (find Sources Tests -name '*.swift' -print0 | xargs -0 swift-format lint --strict --configuration .swift-format; swiftlint lint --strict --config .swiftlint.yml).
  • swift build and swift test run before and after the sweep give identical results: build
    succeeds both times, and both times swift test reports 45 tests in 9 suites, all passing.
  • No Package.resolved drift from any local build/test run.

Closes #53

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/policy only), verified via the
    existing test suite (45/45 passing, identical before and after) rather than new tests,
    since there is 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
#53 before any of this landed. Holding for review before merge, not merging this myself.

Follows OCCTSwiftScripts#114/#115 as the reference implementation for a
repo this size: full sweep, not a gradual exemption manifest. This
repo is small (~2,280 Swift lines, ~19 files, all pure Swift, zero
first-party C++ bridge files), small enough to sweep into full
compliance in one PR and go straight to a blocking gate.

- .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. SwiftLint's defaults duplicate
  swift-format's formatting opinions and add a separate surface of
  code-quality/complexity opinions (identifier_name in particular:
  149 hits measured fresh for this repo, all short conventional
  locals in dense numerical/graph code, none real problems) that
  belong to the ecosystem's code-structure policy, not this one.
- Scripts/comment-ratio-check.sh: report-only nudge, never fails.
  This repo had no Scripts/ directory before; this bootstraps one.
- .github/workflows/code-style.yml: swift-format lint --strict and
  swiftlint lint --strict as blocking gates, comment-ratio as a
  non-blocking step. Pure text analysis, no swift build needed. This
  repo had no CI before; this bootstraps CI from nothing.
- okf/policies/code-style.md: 7th mandatory policy for this repo,
  linked from okf/index.md.
- Full Sources/+Tests/ sweep: swift-format --in-place, plus by-hand
  fixes for the lint-only findings it can't auto-fix: doc-comment
  structure (BeginDocumentationCommentWithOneLineSummary, a blank
  `///` line after the one-sentence summary), Returns:/Throws:
  additions and Parameter -> Parameters: pluralization
  (ValidateDocumentationComments, including the internal parameter
  names ValidateDocumentationComments actually validates against,
  e.g. `bodyID`/`rgba`/`customDeflection`/`useDirectMesh` rather than
  their external argument labels). No AlwaysUseLowerCamelCase or
  EndOfLineComment findings this pass; no orphaned_doc_comment
  findings either. Zero behavior change: doc comments and formatting
  only, no signature or logic changes.
- Incidental: cleared every em-dash found in every file touched by
  this sweep (source, tests, the new scaffold, and the one pre-
  existing em-dash in okf/index.md's frontmatter description), per
  the ecosystem's writing-style policy's own "clear them from any
  file you are already editing" instruction.

Verified locally: swift-format lint --strict and swiftlint lint
--strict both report zero violations. swift build and swift test
give identical results before and after the sweep: build succeeds,
45 tests in 9 suites pass. No Package.resolved drift.

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

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@gsdali
gsdali merged commit 8fcd08d 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 code-style policy CI: swift-format + SwiftLint + comment-ratio check

1 participant