Lines of commented-out code in files¶
ID: py/lines-of-commented-out-code-in-files
Kind: treemap
Severity:
Precision:
Tags:
- maintainability
Click to see the query in the CodeQL repository
This metric counts the number of lines of commented-out code in each file. Large amounts of commented-out code often indicate poorly maintained code.
Example¶
In the following example, a print
statement, originally used for debugging, is left in the code, but commented out. It should be removed altogether.
def area(r):
#if DEBUG:
# print("Computing area of %r" % r)
return r.length * r.width
References¶
Mark Needham: The danger of commenting out code.
Los Techies: Commented Code == Technical Debt.
High Integrity C++ Coding Standard: 2.3.2 Do not comment out code.