forked from github/codeql
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFLinesOfSimilarCode.ql
More file actions
32 lines (29 loc) · 868 Bytes
/
FLinesOfSimilarCode.ql
File metadata and controls
32 lines (29 loc) · 868 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/**
* @name Similar lines in files
* @description The number of lines in a file (including code, comment and whitespace lines)
* occurring in a block of lines that is similar to a block of lines seen
* somewhere else.
* @kind treemap
* @treemap.warnOn highValues
* @metricType file
* @metricAggregate avg sum max
* @precision high
* @id js/similar-lines-in-files
* @tags testability
* duplicate-code
* non-attributable
*/
import external.CodeDuplication
/**
* Holds if line `l` of file `f` belong to a block of lines that is similar to a block
* of lines appearing somewhere else.
*/
predicate simLine(int l, File f) {
exists (SimilarBlock d | d.sourceFile() = f |
l in [d.sourceStartLine()..d.sourceEndLine()]
)
}
from File f, int n
where n = count (int l | simLine(l, f))
select f, n
order by n desc