I want to check my code to find typos like this:
bool check;
check == true; // should be: check = true;
This is a valid code in C/C++, so I want to use cpplint to find code occurrences of this type.
What cpplint configuration should I use?
On
That code will give me two warnings with my compiler settings, which at e both turned into errors.
One warning is for using the == operator without using the result, the other is for using the uninitialised variable check. And obviously any future use of “check” will give a warning again, until the compiler can proof that check is initialised.
This typo indeed can be left unnoticed. I'd suggest you not to rely on default compiler configuration.
Assume following code:
When built with
gcc main.c -o mainthe compiler will not produce any warnings at all. (Ubuntu 20.04.1, GCC 9.3.0).However, when built with
gcc main.c -o main -Wall:You don't need cpplint for this kind of typos. That's an overkill.