-
Notifications
You must be signed in to change notification settings - Fork 2k
Expand file tree
/
Copy pathSimilarFunction.ql
More file actions
35 lines (30 loc) · 958 Bytes
/
SimilarFunction.ql
File metadata and controls
35 lines (30 loc) · 958 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
30
31
32
/**
* @name Similar function
* @description There is another function that is very similar this one. Extract the common code to a common function to improve sharing.
* @kind problem
* @tags testability
* maintainability
* useless-code
* duplicate-code
* statistical
* non-attributable
* @problem.severity recommendation
* @sub-severity low
* @precision very-high
* @id py/similar-function
*/
import python
import CodeDuplication
predicate relevant(Function m) {
m.getMetrics().getNumberOfLinesOfCode() > 10
}
from Function m, Function other, string message, int percent
where similarScopes(m, other, percent, message) and
relevant(m) and
percent > 95.0 and
not duplicateScopes(m, other, _, _) and
not duplicateScopes(m.getEnclosingModule(), other.getEnclosingModule(), _, _) and
not duplicateScopes(m.getScope(), other.getScope(), _, _)
select m, message,
other,
other.getName()