Repository navigation
Align the codebase with CODING_STANDARDS.md - #30
Merged
Merged
Conversation
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".
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.
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-formatdeclaredStandard: Cpp11; it is nowc++17. No formatting output changes..clang-format. They are reformatted with clang-format 21.1.8, and a newformatCI job pins that same release. The generated Cousine font header is listed in.clang-format-ignore.vsr/sceneheader// vsr_core..cppfile includes its own header first, and sibling headers included by relative path are project headers.try/catchin library code (which has over 100 catch sites) with the three boundaries where catching is allowed: translating a throwing third-party orstdcall into a failure return value, rolling back partial state, and stopping exceptions at thread and C-callback edges.Array's constructor now checkscudaMalloc. On failure it logs the error and leaves the array without data.cudaMemcpy. On failure it writes the array as a proxy instead of uninitialized bytes.TransferArrayDatanow checkscudaMemcpy. On failure it sends no data, so the receiver rejects the transfer.new/deleteis replaced withunique_ptr/make_sharedinCopyToSDLTexturePass,Scene::addLayerand the two PLY importers.IncludeCategoriesranked 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.// vsrlabel,// vsr_coreover 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
ctest: 45 of 46 tests pass.vsr::ImageImport(an HDRI row-order assertion attest_ImageImport.cpp:505) fails the same way on unmodifiedmain, so this PR doesn't cause it.TransferArrayData.cpp, which has a logic change, was syntax-checked with the library's compile flags.