forked from github/codeql
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAmbiguousToString.ql
More file actions
27 lines (23 loc) · 842 Bytes
/
AmbiguousToString.ql
File metadata and controls
27 lines (23 loc) · 842 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
/**
* @name An SSA variable without a unique 'toString()'
* @description An ambiguous 'toString()' indicates overlap in the defining
* sub-classes of 'SsaVariable'.
* @kind problem
* @problem.severity error
* @id java/consistency/non-unique-ssa-tostring
* @tags consistency
*/
import java
import semmle.code.java.dataflow.SSA
predicate noToString(SsaVariable v) { not exists(v.toString()) }
predicate multipleToString(SsaVariable v) { 1 < count(v.toString()) }
from SsaVariable ssa, ControlFlowNode n, Variable v, string problem
where
(
noToString(ssa) and problem = "SSA variable without 'toString()' for "
or
multipleToString(ssa) and problem = "SSA variable with multiple 'toString()' results for "
) and
n = ssa.getCFGNode() and
v = ssa.getSourceVariable().getVariable()
select n, problem + v