forked from github/codeql
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConfusingMethodNames.ql
More file actions
28 lines (25 loc) · 863 Bytes
/
ConfusingMethodNames.ql
File metadata and controls
28 lines (25 loc) · 863 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 Confusing method names because of capitalization
* @description Finds methods whose name only differs in capitalization from another method defined in the same class.
* @kind problem
* @problem.severity recommendation
* @precision medium
* @id cs/confusing-method-name
* @tags quality
* maintainability
* readability
*/
import csharp
predicate typeWithConfusingName(ValueOrRefType type) {
strictcount(type.getAMethod().getName()) != strictcount(type.getAMethod().getName().toLowerCase())
}
from Method m, Method n, ValueOrRefType type
where
typeWithConfusingName(type) and
type.fromSource() and
m = type.getAMethod() and
n = type.getAMethod() and
m != n and
m.getName().toLowerCase() = n.getName().toLowerCase() and
m.getName() < n.getName()
select m, "Confusing method name, compare with $@.", n, n.getName()