I have defined a .clang-tidy file, but pio check does not seem to pick it

My platformio.ini:

[env:uno]
platform = atmelavr
board = uno
framework = arduino
lib_deps = feilipu/FreeRTOS@^10.5.1-1
build_flags = -Ilib -Isrc
check_tool = cppcheck, clangtidy

my .clang-tidy file:

---
Checks: "
  -*,
  clang-diagnostic-*,
  clang-analyzer-*,
  bugprone-*,
  cert-*-c,
  misc-*,
  performance-*,
  portability-*,
  readability-*,
  modernize-*,
  -modernize-avoid-c-arrays,
  -modernize-use-nullptr,
  -readability-identifier-length
  "
WarningsAsErrors: ''
HeaderFilterRegex: ''
AnalyzeTemporaryDtors: false
FormatStyle:     none
User:            ubaldot

CheckOptions:
  - { key: readability-identifier-naming.NamespaceCase,          value: lower_case }
  - { key: readability-identifier-naming.ClassCase,              value: CamelCase  }
  - { key: readability-identifier-naming.StructCase,             value: CamelCase  }
  - { key: readability-identifier-naming.UnionCase,              value: CamelCase  }
  - { key: readability-identifier-naming.TemplateParameterCase,  value: CamelCase  }
  - { key: readability-identifier-naming.FunctionCase,           value: lower_case }
  - { key: readability-identifier-naming.VariableCase,           value: lower_case }
  - { key: readability-identifier-naming.PrivateMemberSuffix,    value: _          }
  - { key: readability-identifier-naming.ProtectedMemberSuffix,  value: _          }
  - { key: readability-identifier-naming.MacroDefinitionCase,    value: UPPER_CASE }
  - { key: readability-identifier-naming.ConstantCase,           value: UPPER_CASE }
  - { key: readability-identifier-naming.PointerParameterCase,   value: CamelCase  }
  - { key: readability-identifier-naming.PointerParameterPrefix, value: p          }

when I run pio check it runs both cppcheck and clang-tidy, but the .clang-tidy config file seems to be completely ignored.

This seems to have been addressed by https://github.com/platformio/platformio-core/commit/f7b5a7bed8704dd96595be32cd4358ed801b04ed quite some time ago, you ought to use

check_flags =
  clangtidy: --config-file=.clang-tidy

in the platformio.ini.

1 Like