Standardizing Clang-Tidy Configuration Across OpenBMC Repositories

Jayanth Othayoth ojayanth at gmail.com
Mon Dec 9 22:17:38 AEDT 2024


*All,*

Some OpenBMC repositories are already using clang-tidy to ensure code
quality and adherence to coding standards. To further standardize this
practice, the OpenBMC CI infrastructure will now automatically verify code
quality during check-in if a .clang-tidy file is present in the
repository's root directory, enabling automatic validation.

As part of extending clang-tidy coverage and streamlining its enablement,
proposing the use of a common base configuration in all repositories.
Repository owners can then disable checks that are not required based on
their project needs

*Key Points:*

   - *Standard Configuration:* A reference .clang-tidy.[type] file is
   provided as a base template for all repositories. This template adheres to
   OpenBMC's standards and includes checks recommended by the clang-tidy
   documentation.
   - *Standardization:* All repositories start with the same base
   configuration, ensuring consistent coding standards and checks.
   - *Customization:* Maintainers can adjust the configuration to fit
   specific repository needs. Checks can be disabled by prefixing them with a
   '-'.
   - *C and C++ Checks:* The configuration includes checks for both C and
   C++ code, promoting best practices.
   - *Activation:* To activate clang-tidy, copy the base version file from
   <link>, rename it to .clang-tidy, and place it in the respective
   repository.

*Testing the Configuration:*

Utilizing the existing format-code.sh tool, the common configuration will
be applied and executed as part of CI if found in the root directory,
ensuring no files are modified after running it.

*In Progress:*

   - Updated clang-tidy Documentation:
   https://gerrit.openbmc.org/c/openbmc/docs/+/76369/
   - Published Initial Version of C++ Reference Configuration:
   https://gerrit.openbmc.org/c/openbmc/docs/+/76345/
   - Started Updating and Enabling Repositories with New Clang-Tidy Config
   File: See patch series :
   https://gerrit.openbmc.org/q/topic:%22clang-tidy-base%22
   - Added Commit to Fix Clang-Tidy Build Failures: Provided trivial fixes
   or disabled errors using clang pragmas. Also disabled all failing checks.

*Scope of Activity:*

The current activity focuses on enabling clang-tidy for all active
repositories and adding trivial fixes if required to establish the
clang-tidy base infrastructure. Once this update is completed, repository
owners can start enabling the disabled checks based on their project needs.

*Input Required:*

Looking for timely reviews and early feedback to finalize the process.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ozlabs.org/pipermail/openbmc/attachments/20241209/8aac3bf3/attachment.htm>


More information about the openbmc mailing list