gitlab-ci - 使用 gitlab CI 检查编码风格
问题描述
我使用 clang-format 来格式化我的源代码,并且我想在 gitlab CI 中验证编码风格(变量名前缀、缩进,...)。
我已经使用代码质量来检查变量范围。
我想在代码质量中添加编码样式验证。
有人知道该怎么做吗?
ps:我不是 gitllab 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
推荐阅读
- html - 让两个单选按钮表现为一个复选框
- scons - 如何在分层 Scons 构建中的子目录之间传递构造变量
- amazon-web-services - AWS 键盘 - 如何防止按住 Shift 或 Ctrl 被解释为重复按下键?
- composer-php - 运行 composer install 时供应商文件夹在创建时立即消失
- python - 熊猫根据条件合并
- vue.js - 如何在 vue csp 中的“方法”对象中放入更多对象或类?
- php - 由于冲突,我无法访问以占位符为前缀的路由
- python - 如何根据 keras 中的概率对激活输出进行排序?
- css - 移动菜单 - 汉堡图标 - “悬停”颜色不变,“聚焦”链接不起作用
- python - 如何抑制张量流显示每个类的检测分数以使我的边界框预测可读