Add a standarized way to introduce clang-format for the project and make it mandatory
Opened this issue · 0 comments
gbm25 commented
Issue Description: Standardize Clang-Format Integration and Make It Mandatory
Overview
To ensure consistent code formatting and maintain high code quality across the project, we propose introducing clang-format
as a mandatory part of our development process. This will help us adhere to a unified style guide and make it easier to review code changes.
Objectives
- Standardize Code Formatting: Apply
clang-format
to ensure that all code adheres to a consistent style. - Integrate Formatting into CI/CD: Automatically check that all code complies with
clang-format
rules during the pull request (PR) process. - Enforce Formatting Rules: Prevent merges of PRs that do not comply with the formatting standards.
Implementation Steps
-
Create a
.clang-format
Configuration File:- Define the code style rules in a
.clang-format
file that will be used throughout the project. - The configuration should be placed in the root directory of the project.
- Define the code style rules in a
-
Apply
clang-format
to the Codebase:- Format the existing codebase using the defined
.clang-format
rules. - Commit these changes to ensure that the entire codebase is compliant.
- Format the existing codebase using the defined
-
Set Up a Pre-Commit Hook:
- Create a pre-commit hook to automatically format code before commits are finalized.
- Ensure that developers have
clang-format
installed locally and configure their environment to use the hook.
-
Add a CI/CD Workflow to Check Formatting:
- Create a CI/CD workflow that runs
clang-format
checks on all PRs. - Implement a check that verifies if the code adheres to the formatting rules defined in
.clang-format
. - Fail the CI/CD build if the formatting check fails, preventing the PR from being merged.
- Create a CI/CD workflow that runs
-
Documentation:
- Update the project’s contribution guidelines to include information about the
clang-format
requirements. - Provide instructions for developers on how to set up and use
clang-format
locally.
- Update the project’s contribution guidelines to include information about the
Checklist
- Create and commit a
.clang-format
file. - Format existing codebase and commit changes.
- Develop and test a pre-commit hook for local formatting.
- Set up CI/CD integration for formatting checks.
- Update contribution guidelines with formatting rules and setup instructions.
- Document the process and make sure all developers are aware of the new requirements.
Additional Notes
- Dependencies: Ensure that
clang-format
is available in the build environment or specify the version required. - Exceptions: Consider scenarios where code formatting might not be strictly applicable (e.g., third-party code, generated files) and document any such exceptions.
By implementing these steps, we aim to streamline our code review process and maintain high standards of code quality throughout the project's lifecycle. Your feedback and suggestions are welcome as we work towards this integration.