Too much commented out code can be counter-productive

Too much commented out code can be counter-productive

Software AgilityEmbedded Documentation

This code insight counts the number of comment lines that starts with keywords such as if, else, while, foreach, switch, etc. and ends with “;”, “{” or “}”. Depending on the density of commented out lines compared to total lines of code, Highlight counts penalty points for the scanned source file.

Why you should care

Commented out code – some old code instructions that are left in comments – is one of the most wide-spread issues in source code. It could remain in your software forever, as a developer’s legacy to humanity or just in case it could be reused.  But when found in high density, it can distract the developer on what’s important (the really useful code that will be executed in production), and most of the time this commented out code is quickly obsolete and couldn’t work properly if it was uncommented.


CAST recommendations

Ideally, commented out code should be removed whenever possible from the source. A great majority of development teams work with SCM tools that offers the capability to load previous versions of source code, so leaving code in comments for posterity is not something useful.

About CAST and Highlight’s Code Insights

Over the last 25 years, CAST has leveraged unique knowledge on software quality measurement by analyzing thousands of applications and billions of lines of code. Based on this experience and community standards on programming best practices, Highlight implements hundreds of code insights across 15+ technologies to calculate health factors of a software.

How it worksFeatures & Analytics