Skip to content

chore(#114): trial the ecosystem code-style policy - #115

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

chore(#114): trial the ecosystem code-style policy#115
gsdali merged 1 commit into
mainfrom
chore/114-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),
chosen deliberately ahead of OCCTSwift in the rollout order: this codebase is small (48 files,
~10k lines) so it's one we can fully sweep into compliance in one PR and turn on zero-tolerance
blocking CI immediately, rather than needing OCCTSwift's gradual "if you touch it, you fix it"
exemption-manifest approach. Also the first real test of the CI gates themselves.

Adds:

  • .swift-format (100 col, 4-space — the ecosystem's one deliberate divergence from Google's
    2-space default) + 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
    (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 548 hits on first run, all short conventional locals (i, db, g,
    sv) 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 this repo's own
    bash-script convention rather than 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. Pure text analysis, no swift build
    needed, so it stays cheap even on the macos-15 runner it uses for tool availability.
  • okf/policies/code-style.md: this repo's 8th mandatory policy, linked from okf/index.md and
    CLAUDE.md (count bumped seven → eight).
  • 47 by-hand fixes for lint-only findings swift-format --in-place can't auto-fix: doc-comment
    structure (BeginDocumentationCommentWithOneLineSummary), two Throws: additions and one
    Parameters: pluralization (ValidateDocumentationComments), and two snake_case → camelCase
    renames in Sources/Script/main.swift (c_seg1..10/w_seg1..10cSeg1..10/wSeg1..10,
    local-only, all call sites updated).

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 — this repo's
docs/reference/ documents CLI verbs, not Swift declarations, and Scripts/verb-check.sh /
.github/workflows/verbs.yml already guard that registry-vs-docs consistency.

Zero behavior change. Renames are local-only; everything else is formatting/doc comments.
Verified directly, not just asserted:

  • swift-format lint --strict, swiftlint lint --strict, Scripts/comment-ratio-check.sh,
    Scripts/policy-check.sh all pass locally.
  • Release build succeeds; Scripts/verb-check.sh and Scripts/run-identity-check.sh both pass
    against it.
  • swift test --filter DrawingComposerTests: 3/3 pass (covers the hand-edited files).
  • Scripts/recipe-check.sh: all 7 recipes pass, every one with a reference output.brep matches
    it at Δvol = 0.00e+00 — same geometry, byte-for-byte, before and after the sweep.

One pre-existing, unrelated finding surfaced during verification: a plain debug swift build hits
an OCCTSwift/OCCTSwiftAIS sibling-version link error (Face.SurfaceType symbol not found).
Confirmed present on main before this change too (via git stash + rebuild). The release build
CI actually uses (swift build -c release) is unaffected. Not fixed here, out of scope for a
style/docs pass; flagging in case it's worth its own issue.

Closes #114

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 the existing
    DrawingComposerTests suite and recipe-check.sh's reference-output comparison 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
#114 before any of this landed. Holding for review before merge, per "we'll review and implement."

🤖 Generated with Claude Code

Pilot repo for the ecosystem's code-style policy proposal, chosen
because this codebase is small enough (48 files, ~10k lines) to sweep
into full compliance in one PR and go straight to a blocking gate,
rather than needing OCCTSwift's gradual exemption-manifest approach.

- .swift-format: 100 col, 4-space (the ecosystem's one deliberate
  divergence from Google's 2-space default).
- .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:
  548 hits on first run, 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.
- .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.
- okf/policies/code-style.md: 8th mandatory policy for this repo,
  linked from okf/index.md and CLAUDE.md (count bumped seven -> eight,
  verified against Scripts/policy-check.sh).
- Full Sources/+Tests/ sweep: swift-format --in-place, plus by-hand
  fixes for the 47 lint-only findings it can't auto-fix (doc-comment
  structure, two Throws: additions, one Parameters: pluralization,
  two snake_case->camelCase renames in Sources/Script/main.swift).
  Zero behavior change: renames are local-only, doc comments only.

Verified locally: swift-format lint --strict, swiftlint lint --strict,
comment-ratio-check.sh, and Scripts/policy-check.sh all pass. Release
build succeeds; Scripts/verb-check.sh and Scripts/run-identity-check.sh
both pass against it. (A plain debug `swift build` hits a pre-existing,
unrelated OCCTSwift/OCCTSwiftAIS sibling-version link error, confirmed
present on main before this change too via git stash; the release
build CI actually uses is unaffected.)

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

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