mirror of
https://github.com/github/codeql.git
synced 2026-03-28 10:18:17 +01:00
19 lines
507 B
Plaintext
19 lines
507 B
Plaintext
/**
|
|
* @name Comment ratio in files
|
|
* @description The percentage of lines in a file that contain comments.
|
|
* @kind treemap
|
|
* @treemap.warnOn lowValues
|
|
* @metricType file
|
|
* @metricAggregate avg max
|
|
* @precision very-high
|
|
* @tags maintainability
|
|
* @id js/comment-ratio-per-file
|
|
*/
|
|
|
|
import javascript
|
|
|
|
from File f, int n
|
|
where n = strictsum(TopLevel tl | tl = f.getATopLevel() | tl.getNumberOfLines())
|
|
select f, 100.0 * ((float)f.getNumberOfLinesOfComments() / (float)n) as ratio
|
|
order by ratio desc
|