mirror of
https://github.com/github/codeql.git
synced 2026-03-26 09:18:16 +01:00
17 lines
485 B
Plaintext
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
|