修复cppcheck钩子YAML参数被逗号/空格拆坏导致钩子空转的问题

.pre-commit-config.yaml:
  - args 元素加引号,修正 YAML 流序列解析
  - 此前 --enable 只生效 warning 类别,-I 路径全部失效
  - 新增 --inline-suppr 启用行内抑制注释

App/sys_clock.c:
  - knownConditionTrueFalse 误报行内抑制
  - 闰年 diy=366 分支 cppcheck 数据流未跟踪

docs/pre-commit使用说明.md:
  - 补充 style 类别完整规则详解
  - 新增 YAML 引号陷阱排查方法、行内抑制用法
  - 修正 style 不阻断提交的错误论断
This commit is contained in:
2026-09-01 14:41:05 +08:00
parent 82fcc2b890
commit 0f0d191bf7
3 changed files with 126 additions and 15 deletions
+13 -11
View File
@@ -41,17 +41,19 @@ repos:
- id: cppcheck
name: cppcheck
entry: cppcheck
args: [--enable=warning,performance,portability,style, --error-exitcode=1,
--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=constVariablePointer, --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]
# 注意: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=constVariablePointer', '--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 依赖文件