forked from github/codeql
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMostlySimilarFile.ql
More file actions
28 lines (26 loc) · 858 Bytes
/
MostlySimilarFile.ql
File metadata and controls
28 lines (26 loc) · 858 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
/**
* @name Mostly similar file
* @description There is another file that shares a lot of the code with this file. Notice that names of variables and types may have been changed. Merge the two files to improve maintainability.
* @kind problem
* @problem.severity recommendation
* @precision high
* @id cs/similar-file
* @tags testability
* maintainability
* useless-code
* duplicate-code
* statistical
* non-attributable
*/
import csharp
import CodeDuplication
predicate irrelevant(File f) {
f.getStem() = "AssemblyInfo"
or f.getStem().matches("%.Designer")
}
from File f, File other, int percent
where
similarFiles(f, other, percent)
and not irrelevant(f)
and not irrelevant(other)
select f, percent + "% of the lines in " + f.getBaseName() + " are similar to lines in $@.", other, other.getBaseName()