Question

It just happened to me that I commented out a line of code for testing reasons and ended up checking the code back into the repository with the commented line.

E.g. I set a rule for a job in Eclipse RCP on one line. While developing a new feature I commented out this one line so the rule does not get set.

After a couple of hours the new feature was completed and ready to be commited into SVN. While I changed a lot of things I usually just quickly double-check my changes by doing a synchronize with repository (in Eclipse) and skim through all classes doing some sort of in-mind sanity-check (i.e.: asking myself did I really touch this class?). But I don't check every single line.

So in this case I didn't remember the commented line and it got commited to SVN.

Now, I was wondering if I could find some automatism to prevent these kind of mistakes. I thought about making a code-template or a task-tag and marking the commented line with this. And then check for this task-tag in an svn pre-commit hook.

I googled for some time now but could not find anything. Does anyone know a way of doing this? Or maybe something that gets close to this and just needs minor changes to achieve what I'm looking for?

Was it helpful?

Solution

Borrowing from spong's idea... how about putting some indicator in the comment (FIXME) if it needs to be uncommented. Pre-commit hook can do an svnlook diff and look for FIXME and prevent commit.

OTHER TIPS

You can check such things in a pre-commit hook but i would suggest to use a branch first and check at the end before merging into trunk or an other integration line. On the other hand i would suggest to use unit tests to run them and seeing some are red, based on the commented out code. And last but least, what is so bad to remember about a missed removed comment and do an other commit? And what comes into my mind: Why not using @TODO etc. Tags in Eclipse or better @COMMENT and take a look at the task list in Eclipse?

Open a task view in Eclipse. Then it will show you where you have FIXME in comments:

// FIXME - uncomment this before checking in
// importantThing.execute();
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top