forked from github/codeql
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDuplicateFunction.ql
More file actions
29 lines (26 loc) · 903 Bytes
/
DuplicateFunction.ql
File metadata and controls
29 lines (26 loc) · 903 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
/**
* @name Duplicate function
* @description There is another identical implementation of this function. Extract the code to a common file or superclass to improve sharing.
* @kind problem
* @tags testability
* useless-code
* maintainability
* duplicate-code
* statistical
* non-attributable
* @problem.severity recommendation
* @sub-severity high
* @precision high
* @id py/duplicate-function
*/
import python
import CodeDuplication
predicate relevant(Function m) { m.getMetrics().getNumberOfLinesOfCode() > 5 }
from Function m, Function other, string message, int percent
where
duplicateScopes(m, other, percent, message) and
relevant(m) and
percent > 95.0 and
not duplicateScopes(m.getEnclosingModule(), other.getEnclosingModule(), _, _) and
not duplicateScopes(m.getScope(), other.getScope(), _, _)
select m, message, other, other.getName()