Skip to content

Commit e927c43

Browse files
authored
QL: QL: Actually use the SuffixPredicateCall class as well. Now the query finds 20 results.
1 parent b4d710d commit e927c43

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

ql/src/queries/performance/PrefixSuffixEquality.ql

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,18 @@ bindingset[s]
3636
string escape(string s) { result = s.replaceAll("_", "\\\\_").replaceAll("%", "\\\\%") }
3737

3838
pragma[inline]
39-
string getMessage(Call call, String literal) {
39+
string getMessage(FixPredicateCall call, String literal) {
4040
call instanceof PrefixPredicateCall and
4141
result = ".matches(\"" + escape(literal.getValue()) + "%\")"
4242
or
4343
call instanceof SuffixPredicateCall and
4444
result = ".matches(\"%" + escape(literal.getValue()) + "\")"
4545
}
4646

47-
from EqFormula eq, PrefixPredicateCall call, String literal
47+
class FixPredicateCall extends Call {
48+
FixPredicateCall() { this instanceof PrefixPredicateCall or this instanceof SuffixPredicateCall }
49+
}
50+
51+
from EqFormula eq, FixPredicateCall call, String literal
4852
where eq.getAnOperand() = call and eq.getAnOperand() = literal
4953
select eq, "Use " + getMessage(call, literal) + " instead."

0 commit comments

Comments
 (0)