
Mon, 01/20/2025 - 02:32
Dear OCCT Community,
We are excited to announce that OCCT 7.9 will feature a fully automated code formatting system! This significant update will enforce a consistent code style across the entire OCCT codebase, improving readability and maintainability. *_The pull request implementing these changes is undergoing final reviews and will be merged soon._
We have transitioned to using the clang-format code style, which has been integrated via GitHub Pull Request #246
Additionally, the method guards will be updated in .cxx files from the following format:
//==================================
//function: <function name>
//purpose: empty or single line description
//==================================
bool Function()
{
}
to the following format:
//========[100]========
bool Function()
{
}
Potential Challenges and Solutions:
- Git Blame: While
git blame
can handle whitespace changes with specific flags, this adds complexity.- Solution: We will share the SSH of the global formatting commit, allowing users to easily ignore it in
git blame
. Most GUI Git clients also have options to ignore whitespace changes by default.
- Solution: We will share the SSH of the global formatting commit, allowing users to easily ignore it in
- Cherry-picking Old Changes: Applying patches or cherry-picking changes from older versions onto the reformatted codebase might require extra steps.
- Solution: You can apply the formatting to the old codebase first, then cherry-pick the result onto the new version. This ensures a clean merge. Conversely, cherry-picking newer changes onto an older codebase will be easier, as formatting differences will be minimized.
- Solution (using AI): For small changes, AI tools like GitHub Copilot can help apply modifications across different code formats. This can streamline the process, but always carefully verify the results.
- Custom Patches: Existing patches (as
git diff
) will likely become unusable due to widespread formatting changes.- Solution: You'll need to regenerate patches against the new formatted version. While this requires an initial effort, it ensures compatibility moving forward.
Benefits:
- Single Code Style: This will ensure a consistent code style across the entire codebase.
- Automatic Clear Formatting: Most IDEs and CI/CD pipelines will automatically format the code, making it easier to read and maintain.
- Improved Code Clarity and Readability: The new code style is designed to be more clear and readable.
We hope that you find these changes to be beneficial. If you have any questions, please do not hesitate to contact us.
Thank you for your support of OCCT!
Sincerely, The OCCT3D Development Team