views:

122

answers:

1

It is agreed by many that commented out code is a bad thing if you are using source control.

(And it is agreed by many more, that if you are not using source control, that is even a worse thing).

So the question is, do you know a tool that detected (too much) commented out code?

Do you think such a thing would be a useful [[your-build-tool-here]] plugin?

Ideas on implementing one?

+5  A: 

Next version of http://sonar.codehaus.org (Sonar 1.11 available at the end of September) will detect commented out code for Java and PL/SQL source code.

/*
* someoneCommentMeOutOneDay(); 
* nobodyKnowWhatAmISupposedToDo(); 
* 
* if( youWantToHelpMeToDie() ) { 
*    waitFewWeeks(); 
*    downloadAndRunSonar111(); 
*    findMe(); 
*    deleteMe(); 
* } else { 
*    readCleanCodeBookFromUncleBob(); 
* } 
*/

I've used a probabilistic approach based on patterns detection (ex of pattern: line ends with ';', line contains java keywords, line ends with '{', line contains camelCase words, ...). If a line matches several patterns, the probability is increasing. When a threshold is reached, line is considered to be commented out code line.

Freddy Mallet
any such tool for visual studio?
Tanmoy