Search code examples
c++cpplint

Why cpplint doesn't care about indentation/spaces and what is the alternative?


This is my C++ code:

int    f()   {
               return 1 +      2;
                   }

I'm trying to run it through cpplint:

$ cpplint src/f.cpp
Done processing src/f.cpp

No errors found. What am I doing wrong? Cpplint really does think that this code is properly formatted? If this is really the case, which style checker can help me catch errors in this piece of C++ code?


Solution

  • Cpplint only checks a few special indentation cases, it is not a complete style checker. The cause for this is that cpplint does not property parse files, but checks files line-by-line using regular expressions. That makes it hard to write certain checks for issues that require reasoning about Multi-Line contexts.

    So cpplint does not check for the style flaws of your example.