JS: Remove code duplication library

This commit is contained in:
Asger Feldthaus
2021-03-25 15:20:59 +00:00
parent c812bd948a
commit 446ad5ec9e
11 changed files with 8 additions and 437 deletions

View File

@@ -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