07afb7b468
.pre-commit-config.yaml: 移除 --suppress=constVariablePointer net_select.c: 5 处 p_sock 改 const net_sock_t *(仅只读使用) net_socket.c: net_getsockname 的 p_sock 改 const(只读字段) docs/代码规范/cppcheck使用说明.md: 同步抑制表与处理记录
77 lines
2.6 KiB
YAML
77 lines
2.6 KiB
YAML
# 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
|
|
# 注意:YAML 流序列中逗号是元素分隔符,含逗号/空格的参数必须加引号
|
|
args: ['--enable=warning,performance,portability,style', '--error-exitcode=1',
|
|
'--inline-suppr',
|
|
'--std=c99', '--quiet',
|
|
'--suppress=missingIncludeSystem', '--suppress=missingInclude',
|
|
'--suppress=invalidPrintfArgType_sint', '--suppress=invalidPrintfArgType_uint',
|
|
'--suppress=unusedFunction', '--suppress=unusedStructMember',
|
|
'--suppress=noExplicitConstructor', '--suppress=useStlAlgorithm',
|
|
'--suppress=constParameterPointer', '--suppress=constParameterCallback',
|
|
'--suppress=redundantAssignment',
|
|
'-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]
|