NDepend.API Documentation
PercentageComment Property
NDepend.CodeModel Namespace > ICodeContainer Interface : PercentageComment Property
Gets a numeric float nullable value in the range [0,100] assessing the percentage of comments for this code element.
Syntax
Nullable<float> PercentageComment {get;}

Property Value

null if this code element is defined in a third-party assembly.
null if the PDB file of this assembly or code element parent's assembly, hasen't been found.
null if the source code file path referenced from the PDB file cannot be found.
null if the source code of this code element is written with a programming language different than C#.
Otherwise returns the comments percentage for this code element.
Remarks
This metric value is computed with the following formula: PercentageComment = 100*NbLinesOfComment / ( NbLinesOfComment + NbLinesOfCode).

Recommendations:
Code where the percentage of comment is lower than 20% might need to be more commented. However overly commented code (more than 40%) is not necessarily a blessing as it can be considered as an insult to the intelligence of the reader.
Guidelines about code commenting can be found here.
Requirements

Target Platforms: Windows 11, 10, 8, 7 and Linux, MacOS with net8.0, net7.0 or net6.0 installed

See Also

Reference

ICodeContainer Interface
ICodeContainer Members