cpplint.py
is a style checker for C and C++ that flags code which doesn't follow the
CSE 333 C++ Style Guide. It
checks code organization and layout, not semantics. Run it as you write your
code and again before submitting, and fix whatever it reports.
If it flags something that doesn't apply to CSE 333, raise it on the course discussion board.
Download cpplint.py. The examples
below assume it sits in the root directory of your homework projects; alternatively,
you can give an appropriate path or add its directory to your system $PATH.
.c files and .h headers with C declarations)
Use the --clint option:
$ ./cpplint.py --clint [files to check]
For example:
$ ./cpplint.py --clint hw1/LinkedList.c
hw1/LinkedList.c:44: Missing space before ( in while( [whitespace/parens] [5]
hw1/LinkedList.c:44: Missing space before { [whitespace/braces] [5]
hw1/LinkedList.c:108: Missing space before ( in if( [whitespace/parens] [5]
hw1/LinkedList.c:108: Missing space before { [whitespace/braces] [5]
Done processing hw1/LinkedList.c
Once there are no style issues:
$ ./cpplint.py --clint ex1.c Done processing ex1.c
.cc files and .h headers with C++ declarations)Same command, without --clint:
$ ./cpplint.py [files to check]
For example:
$ ./cpplint.py ex9.cc ex9:10: Closing ) should be moved to the previous line [whitespace/parens] [2] Done processing ex9.cc Total errors found: 1
Once there are no style issues:
$ ./cpplint.py ex10.cc Done processing ex10.cc
The most common issue is a missing execute permission:
$ ./cpplint.py: Permission deniedFix it with
chmod +x cpplint.py. For any other problems, please
use the course discussion board; if common issues surface, we'll add them here.