Opened 10 years ago

Closed 10 years ago

#1612 closed task (fixed)

Remove commented out code that is no longer in use

Reported by: Nicklas Nordborg Owned by: Nicklas Nordborg
Priority: major Milestone: BASE 3.0
Component: core Version:
Keywords: Cc:

Description

I think we should add a general rule to our code guidelines to avoid leaving commented out code in the files. The main reason is that it clutters the code, and it always give me a "headache" when I find it. Why was it commented out? Was it due to some temporary issue that is now fixed? Should the commented out code also be fixed?

I know that when I have been working on #1153 and #1597 I have commented out a lot of code because refactoring made in other places caused it to stop working as intended. The idea was to return later on and fix the code. It was simply to big to try to fix everything in one go. Now I find a lot of older commented out code and can't stop wondering if this is also code that should be fixed or if it can be removed. It's time for a cleanup.

In eclipse, the following regular expression seems to work well to find multi-line comments:

(?s:/\*[^*]([^*]|\*[^/])+;\n)

It will find code blocks starting with /* (but not with /**) that has a semicolon followed by a newline before the end-of-comment */ is found. The key here is that semicolon+newline makes it likely that the comment contains code. We should also try to find single-line comments //.

Change History (2)

comment:1 Changed 10 years ago by Nicklas Nordborg

Owner: changed from everyone to Nicklas Nordborg
Status: newassigned

comment:2 Changed 10 years ago by Nicklas Nordborg

Resolution: fixed
Status: assignedclosed

(In [5689]) Fixes #1612: Remove commented out code that is no longer in use

Added a rule to the coding guidelines to avoid keeping commented out code. If there is a reason for it the commented out part should be tagged with TODO.

The remaining code blocks are part of current tickets and have been tagged with TODO.

Note: See TracTickets for help on using tickets.