如何将 -fix 选项添加到 .clang-tidy 文件

How to add -fix option to .clang-tidy file?

本文关键字:clang-tidy 文件 添加 选项 -fix      更新时间:2023-10-16
Checks: 'modernize-use-auto, modernize-use-nullptr, modernize-loop-convert'
CheckOptions:
  - key:             modernize-loop-convert.MinConfidence
    value:           safe

我有一个这样的配置文件,想添加-fix标志来应用可能的修复程序,但我无法弄清楚它的确切位置。是否可以将-fix-fix-errors标志添加到.clang-tidy文件中?

-fix-fix-errors不是检查选项,而是命令行选项,不能单独配置检查。.clang-tidy文件的可用配置选项在 Clang-tidy 文档中有说明,-fix选项不存在:

$ clang-tidy -dump-config
---
Checks:          '-*,some-check'
WarningsAsErrors: ''
HeaderFilterRegex: ''
FormatStyle:     none
User:            user
CheckOptions:
  - key:             some-check.SomeOption
    value:           'some value'
...

如果要在启用-fix选项的情况下运行配置,只需将其添加到运行clang-tidy的命令中即可。