Test your C++ code for Google style conformity with cpplint.

Test your C++ code for Google style conformity with cpplint.

cpplint is a free tool which will check your C++ code for styling issues and errors. Basically, it will amke sure you code is clean and easy to read.

Many companies follow the Google style guides and this tool will let you check your source code for conformity.

I tested cpplint on my realtime-weapons-detection program to see how terrible my C++ formatting is. Yikes!

Total errors found: 116

Guaranteed to make you cringe!

$ cd ./Test/

$ git clone https://github.com/cpplint/cpplint.git

$ cd ./cpplint

$ ./cpplint.py --counting=detailed --recursive --extensions=cpp ../../Dev/realtime-weapons-detection/src/*
../../Dev/realtime-weapons-detection/src/tester_gun.cpp:129:  An else should appear on the same line as the preceding }  [whitespace/newline] [4]
../../Dev/realtime-weapons-detection/src/tester_gun.cpp:130: { should almost always be at the end of the previous line [whitespace/braces] [4]
../../Dev/realtime-weapons-detection/src/tester_gun.cpp:131: Redundant blank line at the start of a code block should be deleted. [whitespace/blank_line] [2]
../../Dev/realtime-weapons-detection/src/tester_gun.cpp:150: Redundant blank line at the end of a code block should be deleted. [whitespace/blank_line] [3]
../../Dev/realtime-weapons-detection/src/tester_gun.cpp:152: Is this a non-const reference? If so, make const or use a pointer: std::exception& e [runtime/references] [2]
../../Dev/realtime-weapons-detection/src/tester_gun.cpp:153: { should almost always be at the end of the previous line [whitespace/braces] [4]
Done processing ../../Dev/realtime-weapons-detection/src/tester_gun.cpp
Category 'build/include_order' errors found: 8
Category 'build/namespaces' errors found: 5
Category 'legal/copyright' errors found: 2
Category 'runtime/int' errors found: 4
Category 'runtime/references' errors found: 2
Category 'whitespace/blank_line' errors found: 6
Category 'whitespace/braces' errors found: 11
Category 'whitespace/comma' errors found: 12
Category 'whitespace/comments' errors found: 8
Category 'whitespace/end_of_line' errors found: 26
Category 'whitespace/indent' errors found: 5
Category 'whitespace/line_length' errors found: 24
Category 'whitespace/newline' errors found: 1
Category 'whitespace/parens' errors found: 2
Total errors found: 116

Leave a Reply