I have to maintain a large old project project where my forerunners (for lack of version control) have turned large portions of code into comments.
Now that we have everything in version control, I feel we no longer need these comments.
The code in those comments has rotten anyway.
I would like to find the longest of those comments. It would be nice to have a way that gives me all files that have, let’s say, more than 20 consecutive comment lines.
As far as I can tell only // has been used. Finding /* */ is not necessary (probably even harmful because it’d find all the rotten javadoc… sigh).
Howabout this:
The
-Euses ‘extended’ regexesThe
-Rmakes it recurse directoriesThe
-nprints the filnames with line numbersThen you can easily process this list to look for consecutive matches – just look for a block where the line number increases by one per line of output.
This assumes you don’t want to match lines like this:
But only lines that are completely comments:
Update:
Here’s a short Python script to process the output of the above
grep:It won’t treat files with colons in their name correctly, but shouldn’t be hard to modify to deal with that if it’s an issue.