chore(#42): roll out ecosystem code-style policy - #43
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What & why
Rolls out the ecosystem's code-style policy to this repo
(
ecosystemdocs/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's2-space default) copied verbatim from OCCTSwiftScripts, plus a full
swift-format --in-placesweep of
Sources/+Tests/..swiftlint.yml, deliberately narrow (only_rules: [orphaned_doc_comment]). SwiftLint'sdefault 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-structurepolicy rather than this one. Scoped down to the one rule thatcatches something swift-format has no equivalent for.
Scripts/comment-ratio-check.sh: report-only nudge (never fails), bash variant matchingOCCTSwiftScripts' own convention (not the Python style
OCCTSwift/Scripts/uses)..github/workflows/code-style.yml:swift-format lint --strictandswiftlint lint --strictas 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 fromokf/index.md.clang-formatis out of scope,same as noted in the tracking issue.
Hand-fixed lint findings (62 total, everything
swift-format --in-placecouldn't auto-fix)BeginDocumentationCommentWithOneLineSummary. Split a doc comment's first sentence fromits body with a blank
///line, per Google's style guide structure. One genuine swift-formatquirk 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 witha period" even when it does; the fix is moving the possessive inside the span
(
`DragGesture's`), verified empirically against isolated repro cases before applying itacross every occurrence.
orphaned_doc_comment(StandardObjects.swift): a file-level summary comment sat before// MARK: - TrihedronandTrihedron's own (separately documented) doc comment, describing allfour types in the file, not just
Trihedron. Demoted///to//since it's file-scopedcommentary, not documentation of one following declaration, and it doesn't duplicate anything
already documented.
AlwaysUseLowerCamelCase(ManipulatorWidget.swift, local toupdateRotateDrag):R->rotation,M->rotateAboutPivot. Local-only, all call sites in the same functionupdated, no public API change.
EndOfLineComment: moved a trailing//comment that exceeded the line length onto itsown line above, in
SelectionFilterTests.swift(x2) andManipulatorRotateTests.swift.Em-dash cleanup
The ecosystem's
writing-stylepolicy requires clearing em-dashes "from any file you are alreadyediting," not only new ones. Every file
swift-format --in-placeor a hand-fix touched carriedpre-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/#115as thereference), and
.swiftlint.yml's rationale comment cited OCCTSwiftScripts' own548 hitsmeasurementfor
identifier_nameas 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 twopre-existing, unrelated compile errors (confirmed via a clean-tree
git stashbaseline runbefore touching anything):
InteractiveContextMutationTests.swift/RemapTests.swift:value of optional type 'SIMD3<Double>?' must be unwrapped(centroids.enumerated().min { ... }?.offsetneeds aforce-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 linenumber post-sweep since earlier
swift-formatreflow moved the line down.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
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 testcompile failure (see Verification above) is real and reproducible ona clean
maincheckout, unrelated to this change. Flagging rather than fixing, since it's out ofscope for a code-style/formatting PR and touching it would mix an unrelated fix into this diff.
🤖 Generated with Claude Code