mirror of
https://github.com/github/codeql.git
synced 2025-12-24 12:46:34 +01:00
Will need subsequent PRs fixing up test failures (due to deprecated methods moving around), but other than that everything should be straight-forward.
27 lines
675 B
Plaintext
27 lines
675 B
Plaintext
/**
|
|
* @name Similar lines in files
|
|
* @description The number of lines in a file, including code, comment and whitespace lines,
|
|
* which are similar in at least one other place.
|
|
* @kind treemap
|
|
* @treemap.warnOn highValues
|
|
* @metricType file
|
|
* @metricAggregate avg sum max
|
|
* @precision high
|
|
* @tags testability
|
|
* @id py/similar-lines-in-files
|
|
*/
|
|
|
|
import python
|
|
import external.CodeDuplication
|
|
|
|
from File f, int n
|
|
where
|
|
n =
|
|
count(int line |
|
|
exists(SimilarBlock d | d.sourceFile() = f |
|
|
line in [d.sourceStartLine() .. d.sourceEndLine()] and
|
|
not allowlistedLineForDuplication(f, line)
|
|
)
|
|
)
|
|
select f, n order by n desc
|