mirror of
https://github.com/github/codeql.git
synced 2026-05-01 11:45:14 +02:00
JS: Remove code duplication library
This commit is contained in:
@@ -13,27 +13,8 @@
|
||||
* non-attributable
|
||||
*/
|
||||
|
||||
import external.CodeDuplication
|
||||
|
||||
/**
|
||||
* Holds if line `l` of file `f` should be excluded from duplicated code detection.
|
||||
*
|
||||
* Currently, only lines on which an import declaration occurs are excluded.
|
||||
*/
|
||||
predicate whitelistedLineForDuplication(File f, int l) {
|
||||
exists(ImportDeclaration i | i.getFile() = f and i.getLocation().getStartLine() = l)
|
||||
}
|
||||
|
||||
/**
|
||||
* Holds if line `l` of file `f` belongs to a block of lines that is duplicated somewhere else.
|
||||
*/
|
||||
predicate dupLine(int l, File f) {
|
||||
exists(DuplicateBlock d | d.sourceFile() = f |
|
||||
l in [d.sourceStartLine() .. d.sourceEndLine()] and
|
||||
not whitelistedLineForDuplication(f, l)
|
||||
)
|
||||
}
|
||||
import javascript
|
||||
|
||||
from File f, int n
|
||||
where n = count(int l | dupLine(l, f))
|
||||
where none()
|
||||
select f, n order by n desc
|
||||
|
||||
Reference in New Issue
Block a user