2

I am using clang-tidy to lint source code. In the file .clang-tidy i defined:

Checks: '-*,readability-identifier-naming'
CheckOptions:
...
  - { key: readability-identifier-naming.NamespacePrefix,               value: n1_        },
  - { key: readability-identifier-naming.GlobalVariablePrefix,          value: g1_        },
...

myHeader.h:

namespace n1_test
{
...
}

Linting this file with clang-tidy (tried 11.1.0, 13.0.0git(both compiled by myself) and 10.0.0(downloaded)) on Linux Mint 19.2 (Tina)

with:

clang-tidy-11.1.0 -export-fixes=fixes.txt /tmp/clangTest/mylib/source/myHeader.h -- -I/tmp/clangTest/myLib/source

results in:

 warning: invalid case style for global variable 'n1_test' [readability-identifier-naming]
namespace n1_test {
          ^~~~~~~~~~
          g1_n1_test

I don't understand why NamespacePrefix is not working and clang-tidy treats the namespace as a global variable. I also testest NamespaceCase and it isn't working to.

PS: According to the documentation this should work

Chris
  • 315
  • 1
  • 4
  • 17
  • Does your code compile (possibly error from elsewhere)? Else it seems to be a bug. – Jarod42 Feb 19 '21 at 10:29
  • it compiles. Maybe i also have to mentioned, that i got also an error for including list: `.error: 'list' file not found [clang-diagnostic-error] #include ` – Chris Feb 19 '21 at 11:08
  • It seems then that your "installation/configuration" is broken in some ways. Providing system info (mainly windows or *nix) might help I think. And where are standard headers. – Jarod42 Feb 19 '21 at 11:41
  • Linux Mint 19.2 (Tina) – Chris Feb 19 '21 at 11:43

1 Answers1

2

can't use clang-tidy directly on header files. Instead i have to check the cpp file and have to add -header-filter=.* to also check the headers:

clang-tidy-11.1.0 -header-filter=.* -export-fixes=fixes.txt /tmp/clangTest/mylib/source/main.cpp -- -I/tmp/clangTest/myLib/source
Chris
  • 315
  • 1
  • 4
  • 17