引入 pre-commit 自动化代码审查(格式/静态分析/乱码/commit message)
This commit is contained in:
@@ -0,0 +1,75 @@
|
||||
# pre-commit 自动化代码审查配置
|
||||
# 详见 docs/测试说明/自动化代码审查实施.md
|
||||
default_install_hook_types: [pre-commit, commit-msg]
|
||||
|
||||
exclude: |
|
||||
(?x)^(
|
||||
\.opencode/node_modules/|
|
||||
Lib/lvgl/|
|
||||
simulator/|
|
||||
MDK-ARM/RTE/
|
||||
)
|
||||
|
||||
repos:
|
||||
# 1) 通用钩子(官方)
|
||||
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||
rev: v5.0.0
|
||||
hooks:
|
||||
- id: trailing-whitespace
|
||||
- id: end-of-file-fixer
|
||||
- id: check-added-large-files
|
||||
- id: check-merge-conflict
|
||||
- id: check-yaml
|
||||
|
||||
# 2) C 代码格式:只检查,绝不改写(编码铁律)
|
||||
# Route A:暂不启用,待全库格式化基线后再放开
|
||||
# - repo: https://github.com/pre-commit/mirrors-clang-format
|
||||
# rev: v19.1.4
|
||||
# hooks:
|
||||
# - id: clang-format
|
||||
# args: [--dry-run, --Werror]
|
||||
|
||||
# 3) commit message 格式(宽松规则,兼容中文标题)
|
||||
- repo: https://github.com/jorisroovers/gitlint
|
||||
rev: v0.19.1
|
||||
hooks:
|
||||
- id: gitlint
|
||||
|
||||
# 4) 本地自定义钩子(仓库级)
|
||||
- repo: local
|
||||
hooks:
|
||||
- id: cppcheck
|
||||
name: cppcheck
|
||||
entry: cppcheck
|
||||
args: [--enable=warning,performance,portability, --error-exitcode=1,
|
||||
--std=c99, --quiet,
|
||||
--suppress=missingIncludeSystem, --suppress=missingInclude,
|
||||
--suppress=invalidPrintfArgType_sint, --suppress=invalidPrintfArgType_uint,
|
||||
-I Inc -I App -I Drivers/BSP,
|
||||
-I Drivers/STM32F4xx_HAL_Driver/Inc -I Drivers/CMSIS/Include,
|
||||
-I Middlewares/Third_Party/FreeRTOS/Source/include]
|
||||
language: system
|
||||
types: [c]
|
||||
# 仅扫描项目自有代码;排除第三方库与 LVGL 依赖文件
|
||||
exclude: |
|
||||
(?x)^(
|
||||
Drivers/CMSIS/|
|
||||
Drivers/STM32F4xx_HAL_Driver/|
|
||||
Drivers/BSP/UI/|
|
||||
Drivers/BSP/NET/lftpd/|
|
||||
Drivers/BSP/dhara/|
|
||||
Lib/|
|
||||
Middlewares/|
|
||||
MDK-ARM/|
|
||||
test/
|
||||
)
|
||||
- id: no-mojibake
|
||||
name: Forbid U+FFFD mojibake
|
||||
entry: python scripts/check_mojibake.py
|
||||
language: system
|
||||
types: [c]
|
||||
# 已知历史遗留损坏文件(HEAD 已含 U+FFFD,修复前豁免)
|
||||
exclude: |
|
||||
(?x)^(
|
||||
Drivers/BSP/TPAFE5160/tpafe5160\.c
|
||||
)
|
||||
Reference in New Issue
Block a user