I would like to use clang-tidy 'readability-identifier-naming' module to clean my code, but I failed to use it properly on a short example with class attribute and method.
I used the following .clang-tidy file:
Checks: '-*,readability-identifier-naming'
CheckOptions:
- { key: readability-identifier-naming.ClassCase, value: CamelCase }
- { key: readability-identifier-naming.VariableCase, value: lower_case }
- { key: readability-identifier-naming.FunctionCase, value: lower_case }
- { key: readability-identifier-naming.MemberPrefix, value: m_ }
- { key: readability-identifier-naming.ParameterCase, value: lower_case }
on this code:
class one_class
{
public:
int OneMethod(int OneArgument);
int OneAttribute;
};
int one_class::OneMethod(int OneArgument)
{
OneAttribute = 42;
return OneArgument + 1;
}
int main(void)
{
int OneVariable = 0;
one_class c;
OneVariable = c.OneMethod(OneVariable);
c.OneAttribute = 21;
return 0;
}
The result is this code:
class OneClass
{
public:
int one_method(int one_argument);
int m_OneAttribute;
};
int OneClass::one_method(int one_argument)
{
OneAttribute = 42; // must be m_OneAttribute =
return one_argument + 1;
}
int main(void)
{
int one_variable = 0;
OneClass c;
one_variable = c.OneMethod(one_variable); // must be c.one_method(...)
c.OneAttribute = 21; // must be c.m_OneAttribute = ...
return 0;
}
The declaration and the definition of the class method OneMethod() has been properly transformed, BUT the method call in the main() function has NOT. The same for the class attribute OneAttribute. The resulting code doesn't compile anymore.
I called clang-tidy with this command line :
clang-tidy-5.0 -checks='readability-identifier-naming' -fix test.cpp --
I have clang 5.0 and clang 3.8 installed from packages on an Ubuntu 16.04.
What am I doing wrong ?