Skip to content

Align the codebase with CODING_STANDARDS.md - #30

Merged
jeffamstutz merged 6 commits into
mainfrom
coding-standards-cleanup
Nov 14, 2026
Merged

jeffamstutz merged 6 commits into
mainfrom
coding-standards-cleanup

Conversation

@jeffamstutz

Copy link
Copy Markdown
Collaborator

Brings the code and the standards document back in line with each other, following an audit of the tree against CODING_STANDARDS.md. Each commit is one self-contained step.

Changes

  • clang-format language standard — .clang-format declared Standard: Cpp11; it is now c++17. No formatting output changes.
  • Format the tree and enforce it in CI — 115 files had drifted from .clang-format. They are reformatted with clang-format 21.1.8, and a new format CI job pins that same release. The generated Cousine font header is listed in .clang-format-ignore.
  • CODING_STANDARDS.md
    • Fixes the §3 example that labeled a vsr/scene header // vsr_core.
    • Documents two patterns most files already follow: a .cpp file includes its own header first, and sibling headers included by relative path are project headers.
    • Replaces §11's flat ban on try/catch in library code (which has over 100 catch sites) with the three boundaries where catching is allowed: translating a throwing third-party or std call into a failure return value, rolling back partial state, and stopping exceptions at thread and C-callback edges.
  • CUDA error checks and owning pointers
    • Array's constructor now checks cudaMalloc. On failure it logs the error and leaves the array without data.
    • Array serialization now checks cudaMemcpy. On failure it writes the array as a proxy instead of uninitialized bytes.
    • TransferArrayData now checks cudaMemcpy. On failure it sends no data, so the receiver rejects the transfer.
    • Raw new/delete is replaced with unique_ptr/make_shared in CopyToSDLTexturePass, Scene::addLayer and the two PLY importers.
  • Include sort order — IncludeCategories ranked headers in the reverse of §3's order. It now ranks project headers, then external libraries, then the standard library. 24 files change, all by reordering includes.
  • Include group labels — about 100 files had wrong group labels: an umbrella // vsr label, // vsr_core over scene headers, anari, VTK and CUDA headers under // std, and test helpers under // catch. Each such block is now split into one correctly labeled group per library.

Testing

  • Local Release build with CUDA, Lua, TBB and the interactive apps succeeds after every commit.
  • ctest: 45 of 46 tests pass. vsr::ImageImport (an HDRI row-order assertion at test_ImageImport.cpp:505) fails the same way on unmodified main, so this PR doesn't cause it.
  • Not compiled locally: networking, USD, assimp, VTK and MPI. The changes in those files are whitespace or include reordering only. TransferArrayData.cpp, which has a logic change, was syntax-checked with the library's compile flags.

The project builds as C++17, but .clang-format still declared the
deprecated Cpp11 spelling. Formatting output is unchanged.
115 source files had drifted from .clang-format. Reformat them with
clang-format 21.1.8. Apart from sorting includes within their existing
groups, the changes are whitespace only.

Add a format job to CI that pins the same clang-format release, since
other releases format differently. The generated Cousine font header is
listed in .clang-format-ignore so it is neither reformatted nor checked.
The include-order example in §3 labeled a vsr_scene header as vsr_core.
§3 also never covered two patterns most files follow: a .cpp file
including its own header first, unlabeled, and app-local headers
included by relative path.

§11 banned try/catch in library code outright, but the library has over
a hundred catch sites, nearly all at legitimate boundaries. Replace the
ban with the three boundaries where catching is allowed: translating a
throwing third-party or std call into a fallible return, rolling back
partial state, and stopping exceptions at thread and C-callback edges.
Array's constructor ignored the result of cudaMalloc, so a failed
allocation left an array whose data pointer was never set. It now logs
the CUDA error and leaves the array without data, the same state as a
zero-sized array.

Serializing a CUDA array and sending one over the network both ignored
cudaMemcpy failures and wrote the uninitialized host buffer. On failure,
serialization now writes the array as a proxy, and TransferArrayData
sends no data so the receiver rejects the transfer.

Replace raw new/delete with owning smart pointers in
CopyToSDLTexturePass (its pimpl), Scene::addLayer and the PLY and 3DGS
PLY importers' file streams.
IncludeCategories ranked <x.h> headers first, then other angle-bracket
headers, then quoted ones, the reverse of the order in
CODING_STANDARDS.md section 3. It only mattered inside include blocks
with no group labels, but there it moved project headers below the
standard library.

Rank quoted (project) headers first, angle-bracket headers with a path
or extension (external libraries) next, and bare <name> headers (the
standard library) last, then reformat. 24 files change, all by
reordering includes.
Many include blocks named the wrong group: a single "// vsr" label over
headers from several libraries (mostly tests), "// vsr_core" over
vsr/scene headers, anari, VTK and CUDA headers under "// std", and local
test helpers under "// catch".

Split each such block into one labeled group per library, ordered as
CODING_STANDARDS.md section 3 requires: project groups, then external
libraries, then the standard library. C and OS system headers such as
<unistd.h> stay under "// std".
@jeffamstutz
jeffamstutz merged commit 14d017a into main Nov 14, 2026
13 checks passed
@jeffamstutz
jeffamstutz deleted the coding-standards-cleanup branch November 14, 2026 05:11
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.

1 participant