Percentage of Comments
Percentage of comment compared to logical lines of code. Extracted from C# source only so far; VB.NET support is planned.
CQLinq source
This trend metric is written in CQLinq, C# LINQ over the NDepend code model. It ships with every new NDepend project: you can read it, adapt it, or use it as a starting point for your own custom rules.
// <TrendMetric Name="Percentage of Comments" Unit="%" />
// Application code only: test code (the TestCode view) is not counted
let loc = (double)Application.Assemblies.Sum(a => a.NbLinesOfCode ?? 0)
let comments = (double)Application.Assemblies.Sum(a => a.NbLinesOfComment ?? 0)
select (loc + comments) == 0d ? (double?)null : 100d * comments / (loc + comments)
//<Desc>
// Percentage of comment compared to **logical** lines of code. Extracted
// from C# source only so far; VB.NET support is planned.
//</Desc>
Open in the interactive Rules Explorer · All default rules
Trend Metrics / Code Size: all 22 items
- # Lines of Code
- # Lines of Code (JustMyCode)
- # Lines of Code (NotMyCode)
- # Lines of Code Added since the Baseline
- # Source Files
- # Line Feed
- # IL Instructions
- # IL Instructions (NotMyCode)
- # Lines of Comments
- Percentage of Comments
- # Assemblies
- # Namespaces
- # Types
- # Public Types
- # Classes
- # Abstract Classes
- # Interfaces
- # Structures
- # Methods
- # Abstract Methods
- # Concrete Methods
- # Fields