Skip to content

Commit c82b5eb

Browse files
committed
Java: Remove code duplication library.
1 parent 4b7440d commit c82b5eb

10 files changed

Lines changed: 14 additions & 330 deletions

java/ql/src/Metrics/Files/FLinesOfDuplicatedCode.ql

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,8 @@
1212
* modularity
1313
*/
1414

15-
import external.CodeDuplication
15+
import java
1616

1717
from File f, int n
18-
where
19-
n =
20-
count(int line |
21-
exists(DuplicateBlock d | d.sourceFile() = f |
22-
line in [d.sourceStartLine() .. d.sourceEndLine()] and
23-
not whitelistedLineForDuplication(f, line)
24-
)
25-
)
18+
where none()
2619
select f, n order by n desc

java/ql/src/Metrics/Files/FLinesOfSimilarCode.ql

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,8 @@
1111
* @tags testability
1212
*/
1313

14-
import external.CodeDuplication
14+
import java
1515

1616
from File f, int n
17-
where
18-
n =
19-
count(int line |
20-
exists(SimilarBlock d | d.sourceFile() = f |
21-
line in [d.sourceStartLine() .. d.sourceEndLine()] and
22-
not whitelistedLineForDuplication(f, line)
23-
)
24-
)
17+
where none()
2518
select f, n order by n desc

java/ql/src/external/CodeDuplication.qll

Lines changed: 0 additions & 268 deletions
This file was deleted.

java/ql/src/external/DuplicateAnonymous.ql

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,8 @@
1515
*/
1616

1717
import java
18-
import CodeDuplication
1918

2019
from AnonymousClass c, AnonymousClass other
21-
where
22-
duplicateAnonymousClass(c, other) and
23-
not fileLevelDuplication(c.getCompilationUnit(), other.getCompilationUnit())
20+
where none()
2421
select c, "Anonymous class is identical to $@.", other,
2522
"another anonymous class in " + other.getFile().getStem()

java/ql/src/external/DuplicateBlock.ql

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,10 @@
88
* @id java/duplicate-block
99
*/
1010

11-
import CodeDuplication
11+
import java
1212

13-
from DuplicateBlock d, DuplicateBlock other, int lines, File otherFile, int otherLine
14-
where
15-
lines = d.sourceLines() and
16-
lines > 10 and
17-
other.getEquivalenceClass() = d.getEquivalenceClass() and
18-
other != d and
19-
otherFile = other.sourceFile() and
20-
otherLine = other.sourceStartLine()
13+
from BlockStmt d, int lines, File otherFile, int otherLine
14+
where none()
2115
select d,
2216
"Duplicate code: " + lines + " lines are duplicated at " + otherFile.getStem() + ":" + otherLine +
2317
"."

java/ql/src/external/DuplicateMethod.ql

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,8 @@
1616
*/
1717

1818
import java
19-
import CodeDuplication
20-
21-
predicate relevant(Method m) {
22-
m.getNumberOfLinesOfCode() > 5 and not m.getName().matches("get%")
23-
or
24-
m.getNumberOfLinesOfCode() > 10
25-
}
2619

2720
from Method m, Method other
28-
where
29-
duplicateMethod(m, other) and
30-
relevant(m) and
31-
not fileLevelDuplication(m.getCompilationUnit(), other.getCompilationUnit()) and
32-
not classLevelDuplication(m.getDeclaringType(), other.getDeclaringType())
21+
where none()
3322
select m, "Method " + m.getName() + " is duplicated in $@.", other,
3423
other.getDeclaringType().getQualifiedName()

java/ql/src/external/MostlyDuplicateClass.ql

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,7 @@
1616
*/
1717

1818
import java
19-
import CodeDuplication
2019

2120
from Class c, string message, Class link
22-
where
23-
mostlyDuplicateClass(c, link, message) and
24-
not fileLevelDuplication(c.getCompilationUnit(), _)
21+
where none()
2522
select c, message, link, link.getQualifiedName()

java/ql/src/external/MostlyDuplicateFile.ql

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,8 @@
1616
*/
1717

1818
import java
19-
import CodeDuplication
2019

2120
from File f, File other, int percent
22-
where duplicateFiles(f, other, percent)
21+
where none()
2322
select f, percent + "% of the lines in " + f.getStem() + " are copies of lines in $@.", other,
2423
other.getStem()

0 commit comments

Comments
 (0)