How to discriminate commented code and documentation comments

After using version control tools, it is no longer necessary to comment out old code.
However, some team members still comment out old code. Therefore, I want to clean them up.

I want to mark commented lines which are really comments / documentation, so that every time I do not need to re-read all commented regions. The unmarked lines left are new commented code.

How do I achieve this? Any existing tools or need to write on my own?

Similar concept: in git, we have ‘partial commit’ to select some lines to commit.
However, the lines marked in ‘partial commit’ is valid once only.

1

Don’t mark comments as comments, if you find commented out code while working in a file just delete it. Also try to get those that still insist on commenting out code to stop doing that, nothing is going to change unless you can stop people from commenting out blocks of bad code and not just deleting them. Then its just a simple matter of your team all working together to eliminate commented code when they find it, trying to make those that left commented code go back and clean it up is just a recipe for unnecessary drama.

2

Be careful, because documentation comments sometimes also contain code examples. You want to keep those. For example:

/**
  * This class does something.
  * Usage:
  * <code>
  * MyClass.doSomething();
  * </code>
  */

There is probably no error-proof method, but you could write a short Perl script that finds all comments in the code, keeps the documentation comments, and then makes a guess about the remaining ones using a few regular expressions for the beginning of the comment.

I think that the “nuke on sight” strategy suggested by @Ryathal is sound.

If you want to detect commented out code (please don’t call it “commented code” because lots of people think that means code with comments!) then I think you are going to need to do this by examining the diffs between successive versions. Even then it is not straight forward because there is a variety of ways to comment out code … depending on the programming language.

If you want an automated solution you could parse the comments to see if they are valid code. In general this would identify commented out code. Example code is one thing you have to be wary of accidentally deleting. Though you could check if there is a somewhat standard way of formatting them that you could use to identify or ignore them. E.g. they are in a header or function comment block, or marked in some other way.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật