.clang-tidy 4.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. ---
  2. Checks: '-*,
  3. clang-analyzer-core.*,
  4. clang-analyzer-cplusplus.*,
  5. modernize-redundant-void-arg,
  6. modernize-use-bool-literals,
  7. modernize-use-equals-default,
  8. modernize-use-nullptr,
  9. modernize-use-override,
  10. google-explicit-constructor,
  11. google-readability-casting,
  12. readability-braces-around-statements,
  13. readability-identifier-naming.ClassCase,
  14. readability-identifier-naming.StructCase,
  15. readability-identifier-naming.TypedefCase,
  16. readability-identifier-naming.EnumCase,
  17. readability-non-const-parameter,
  18. cert-dcl21-cpp,
  19. bugprone-undelegated-constructor,
  20. bugprone-macro-parentheses,
  21. bugprone-macro-repeated-side-effects,
  22. bugprone-forward-declaration-namespace,
  23. bugprone-bool-pointer-implicit-conversion,
  24. bugprone-misplaced-widening-cast,
  25. cppcoreguidelines-narrowing-conversions,
  26. misc-unconventional-assign-operator,
  27. misc-unused-parameters'
  28. WarningsAsErrors: ''
  29. HeaderFilterRegex: ''
  30. CheckOptions:
  31. # 现代化(Modernize)
  32. - key: modernize-redundant-void-arg
  33. value: 'true' # 检查并移除函数声明中冗余的 void 参数。
  34. - key: modernize-use-bool-literals
  35. value: 'true' # 建议使用布尔字面量 true 和 false 代替整数值 0 和 1。
  36. - key: modernize-use-equals-default
  37. value: 'true' # 建议在默认构造函数、复制构造函数和赋值运算符中使用 = default,以简化代码。
  38. - key: modernize-use-nullptr
  39. value: 'true' # 建议使用 nullptr 代替 NULL 或 0 来表示空指针。
  40. - key: modernize-use-override
  41. value: 'true' # 建议在覆盖基类虚函数时使用 override 关键字,以增加代码的清晰性和安全性。
  42. # Google 代码风格(Google)
  43. - key: google-explicit-constructor
  44. value: 'true' # 检查并建议在单参数构造函数中使用 explicit 关键字,以防止隐式转换。
  45. - key: google-readability-casting
  46. value: 'false' # 检查并建议使用 C++ 风格的类型转换(如 static_cast、dynamic_cast、const_cast 和 reinterpret_cast)代替 C 风格的类型转换。
  47. # 可读性(Readability)
  48. - key: readability-braces-around-statements
  49. value: 'true' # 建议在单行语句周围添加大括号,以提高代码的可读性和一致性。
  50. - key: readability-identifier-naming.ClassCase
  51. value: 'CamelCase' # 类名应使用 CamelCase 风格,例如 MyClassName。
  52. - key: readability-identifier-naming.StructCase
  53. value: 'CamelCase' # 结构体名应使用 CamelCase 风格,例如 MyStructName。
  54. - key: readability-identifier-naming.TypedefCase
  55. value: 'CamelCase' # 类型定义应使用 CamelCase 风格,例如 MyTypeDef。
  56. - key: readability-identifier-naming.EnumCase
  57. value: 'CamelCase' # 枚举名应使用 CamelCase 风格,例如 MyEnumName。
  58. - key: readability-non-const-parameter
  59. value: 'true' # 检查并标识非 const 参数,以提高代码的可读性和安全性。
  60. # CERT 安全编码标准(CERT)
  61. - key: cert-dcl21-cpp
  62. value: 'true' # 检查并标识在头文件中不应包含无命名空间的 using 声明和指令,以防止命名空间污染。
  63. # Bug 检测(Bugprone)
  64. - key: bugprone-undelegated-constructor
  65. value: 'true' # 检查并标识未委托的构造函数,以确保构造函数的正确性。
  66. - key: bugprone-macro-parentheses
  67. value: 'true' # 检查并建议在宏定义中使用括号,以防止潜在的错误。
  68. - key: bugprone-macro-repeated-side-effects
  69. value: 'true' # 检查并标识宏中重复的副作用,以防止潜在的错误。
  70. - key: bugprone-forward-declaration-namespace
  71. value: 'true' # 检查并标识命名空间前向声明的潜在问题。
  72. - key: bugprone-bool-pointer-implicit-conversion
  73. value: 'true' # 检查并标识布尔指针的隐式转换,以防止潜在的错误。
  74. - key: bugprone-misplaced-widening-cast
  75. value: 'true' # 检查并标识错误的宽化转换,以防止潜在的错误。
  76. # C++ 核心指南(CppCoreGuidelines)
  77. - key: cppcoreguidelines-narrowing-conversions
  78. value: 'true' # 检查并标识可能导致数据丢失的窄化转换。
  79. # 杂项(Miscellaneous)
  80. - key: misc-unconventional-assign-operator
  81. value: 'true' # 检查并标识不常见的赋值操作符重载,以确保代码的一致性和可维护性。
  82. - key: misc-unused-parameters
  83. value: 'true' # 检测未使用的参数。
  84. ...