Files
codeql/javascript/ql/src/Metrics/FCommentRatio.ql
2021-03-25 15:12:09 +00:00

17 lines
485 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
* @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 * (f.getNumberOfLinesOfComments().(float) / n.(float)) as ratio order by ratio desc