Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit bd49343

Browse files
committed
Python: Remove code duplication library
1 parent 09fbf48 commit bd49343

30 files changed

Lines changed: 13 additions & 1207 deletions

python/ql/src/Metrics/FLinesOfDuplicatedCode.ql

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,7 @@
1212
*/
1313

1414
import python
15-
import external.CodeDuplication
1615

1716
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 allowlistedLineForDuplication(f, line)
24-
)
25-
)
17+
where none()
2618
select f, n order by n desc

python/ql/src/Metrics/FLinesOfSimilarCode.ql

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,7 @@
1212
*/
1313

1414
import python
15-
import external.CodeDuplication
1615

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

python/ql/src/external/CodeDuplication.qll

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

python/ql/src/external/DuplicateBlock.ql

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,7 @@
1616
*/
1717

1818
import python
19-
import CodeDuplication
2019

21-
predicate sorted_by_location(DuplicateBlock x, DuplicateBlock y) {
22-
if x.sourceFile() = y.sourceFile()
23-
then x.sourceStartLine() < y.sourceStartLine()
24-
else x.sourceFile().getAbsolutePath() < y.sourceFile().getAbsolutePath()
25-
}
26-
27-
from DuplicateBlock d, DuplicateBlock other
28-
where
29-
d.sourceLines() > 10 and
30-
other.getEquivalenceClass() = d.getEquivalenceClass() and
31-
sorted_by_location(other, d)
32-
select d,
33-
"Duplicate code: " + d.sourceLines() + " lines are duplicated at " +
34-
other.sourceFile().getShortName() + ":" + other.sourceStartLine().toString()
20+
from BasicBlock d
21+
where none()
22+
select d, "Duplicate code: " + "-1" + " lines are duplicated at " + "<file>" + ":" + "-1"

python/ql/src/external/DuplicateFunction.ql

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,7 @@
1616
*/
1717

1818
import python
19-
import CodeDuplication
2019

21-
predicate relevant(Function m) { m.getMetrics().getNumberOfLinesOfCode() > 5 }
22-
23-
from Function m, Function other, string message, int percent
24-
where
25-
duplicateScopes(m, other, percent, message) and
26-
relevant(m) and
27-
percent > 95.0 and
28-
not duplicateScopes(m.getEnclosingModule(), other.getEnclosingModule(), _, _) and
29-
not duplicateScopes(m.getScope(), other.getScope(), _, _)
20+
from Function m, Function other, string message
21+
where none()
3022
select m, message, other, other.getName()

python/ql/src/external/MostlyDuplicateClass.ql

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

1818
import python
19-
import CodeDuplication
2019

2120
from Class c, Class other, string message
22-
where
23-
duplicateScopes(c, other, _, message) and
24-
count(c.getAStmt()) > 3 and
25-
not duplicateScopes(c.getEnclosingModule(), _, _, _)
21+
where none()
2622
select c, message, other, other.getName()

python/ql/src/external/MostlyDuplicateFile.ql

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@
1616
*/
1717

1818
import python
19-
import CodeDuplication
2019

21-
from Module m, Module other, int percent, string message
22-
where duplicateScopes(m, other, percent, message)
20+
from Module m, Module other, string message
21+
where none()
2322
select m, message, other, other.getName()

python/ql/src/external/MostlySimilarFile.ql

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

1818
import python
19-
import CodeDuplication
2019

2120
from Module m, Module other, string message
22-
where similarScopes(m, other, _, message)
21+
where none()
2322
select m, message, other, other.getName()

0 commit comments

Comments
 (0)