Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tool to detect style issues for c++ code?

I am inheriting a fairly large code base which unfortunately exhibits a lot of "bad habits". One of my largest personal pet peeves is declaring several variables in one expression like this:

int x, y, z;

personally, I prefer:

int x;
int y;
int z;

this allows me to easily adjust the types individually, and avoids issues with pointer types like this:

int *x, y, z; // whoops I meant to make y and z pointers too!

Also, I'd love to detect when a type whose size is bigger than sizeof(void*) is being passed by value.

There are other "style" issues I'd like to detect and correct as well, but these are the most annoying IMO. What are the best tools for this?

like image 420
Evan Teran Avatar asked Nov 03 '11 16:11

Evan Teran


2 Answers

One of the best tools I have used, for checking the style of C++ files is the KWStyle. However I am not quite sure if it supports all your requirements.

like image 129
pnezis Avatar answered Sep 24 '22 00:09

pnezis


I use Artistic Style or astyle for formatting my codes of C++ and JAVA since about 2 Years.It can be customized in great detail.Probably there are many better ones now...

But Its Very useful to me.

like image 33
bilash.saha Avatar answered Sep 25 '22 00:09

bilash.saha