gitlab cicd集成clang-format做编码风格检查

1. clang-format工具安装

在本地shell环境管理git代码仓库,需要先安装clang-format工具。 安装指令:

apt-get update && apt-get install -y clang-format

安装成功后,执行clang-format --version

可以看到clang-format的版本号。

clang-format version 10.0.0-4ubuntu1

推荐大家安装与这个版本一致的clang-format软件版本。

2. clang-format检查编码风格

2.1 开发本地检查编码风格

规则文件名为.clang-format,在代码仓库的根目录下
如果使用谷歌编码风格,.clang-format文件内容:

# Run manually to reformat a file:
# clang-format -i --style=file <file>
Language:        Cpp
BasedOnStyle:  Google
# 对#include 行的做格式化,但不要求#include按照项目文件、系统文件、其他文件的顺序排序
IncludeCategories:
  - Regex:           '^"(udp_service|idl_wrapper|communication/common/types|dataflow/module/port|dataflow/module_loader/register_module_macro|log|udp_service_parms)"'
    Priority:        1
  - Regex:           '^<.*\.h>'
    Priority:        2
  - Regex:  
  • 47
    点赞
  • 24
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值