views:

133

answers:

3

Earlier today I asked a question about enforcing coding standards. Someone mention about NDepend tool that does code analysis. It looks like this tools does a lot of good thing to help developers to write higher quality code. The problem is that NDepend is not free (I obviously got spoiled by Open Source projects).

I don't mind to spend money if this tool will help my team to produce higher quality code.

Here comes my question. Actually I have two questions:

  1. Is there a free tool simlar to NDepend?
  2. How do you incorporate NDepend or similar tool with your build process?

I understand that the best way to guarantee code quality is code reviews. And I don't expect a tool to replace code review.

Thank you

+2  A: 

The best tool for producing higher quality code is higher quality programmers. No tool can compensate for that.

Jeffrey Kemp
Actually I planed to put in my question that code review is best practice to guarantee code quality. But I'm still looking for tool that will enforce it during check ins. But I missed it. I'm going to add it now.
Vadim
Totally agree - code reviews are also vital. Sorry, I don't know of any tools.
Jeffrey Kemp
@Vadim: if you want it done by tools, check out the Aegis CM system by Peter Miller. It's on SourceForge at http://aegis.sourceforge.net/ and it requires tests that pass before checkin is allowed. If the build is set stringent (see my answer), this could help with the checkin part.
Jonathan Leffler
+2  A: 

Although, as Jeffrey Kemp says, high quality programmers produce high quality code, you can use your build process as a way to help ensure that your programmers (of whatever quality they are) do not have lapses of concentration.

One primary method is to ensure that your compilations are done with appropriately stringent compiler warning levels. What that means depends on the language, but for C and GCC (GNU Compiler Collection), you might use:

-Werror -Wall -Wmissing-prototypes -Wstrict-prototypes

This says 'any warning will be treated as an error' (so the build will fail until the warning is fixed), warn about a lot of common problems, and in particular, insist that non-static functions have a prototype in scope before being used or defined, and static functions have a prototype or definition in scope before being used, and insist on strict prototypes - do not allow the declaration notation 'extern int function();' which means (in C, but not C++) a function that returns an int with indeterminate - not empty - argument list; it also means no K&R (non-prototype) function definitions. If you're really up to speed, consider adding -Wextra.

Other languages have other issues. In Java, you probably want to compile with the -deprecated option (spelled correctly if I've misspelled it), and so on.

Then ensure that coding issues are fixed - and fixed properly, not by scattering casts around willy-nilly - before the build passes.

One advantage of ensuring that the fixes for these problems are done by the people who change things so that the previously clean-compiling code no longer compiles cleanly is that those people are too busy fixing the code to write more code that doesn't compile properly. But code review by competent, stringent and patient pedagogues is also important; the guilty parties have to be taught how to deal with the mess they make.

Jonathan Leffler
A: 

The NDepend website proposes new documentations about integrating NDepend in a build process, check it out, like for example:

Customize NDepend Analysis

Patrick Smacchia - NDepend dev