首页 > 解决方案 > 使用 gitlab CI 检查编码风格

问题描述

我使用 clang-format 来格式化我的源代码,并且我想在 gitlab CI 中验证编码风格(变量名前缀、缩进,...)。

我已经使用代码质量来检查变量范围。

我想在代码质量中添加编码样式验证。

有人知道该怎么做吗?

ps:我不是 gitllab CI 专家。

标签: gitlab-ci

解决方案


我找到了这个解决方案,将休闲线添加到.gitlab-ci.yml

format:
  stage: test
  image: nexus.lumiplan.com:8443/toolchain/clang-format:13
  needs: []
  script:
    - find rootToYourProject \( \( -name \*.cpp -o -name \*.h \) -a ! -iname \*soap\* \) -print0 | xargs -0 -n 1 clang-format-13 --Werror -n --verbose
  only:
    - merge_requests

使用这个脚本,我可以验证我的 clang 格式配置到除了soap 文件之外的所有文件.cpp.h


推荐阅读