4

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?

2
  • 2
    You seem to have described an excellent way of solving this problem. What prevents you from implementing it?
    – Anonymoose
    May 12, 2010 at 8:03
  • Nothing. :-) But I could not imagine that there is no solution already out there...
    – Jens
    May 17, 2010 at 12:10

3 Answers 3

1

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.

1

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?

0

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();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.