-
Notifications
You must be signed in to change notification settings - Fork 2k
Expand file tree
/
Copy pathOctalLiteral.ql
More file actions
25 lines (23 loc) · 857 Bytes
/
OctalLiteral.ql
File metadata and controls
25 lines (23 loc) · 857 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
/**
* @name Use of octal values
* @description An integer literal that starts with '0' may cause a problem. If the '0' is
* intentional, a programmer may misread the literal as a decimal literal. If the '0'
* is unintentional and a decimal literal is intended, the compiler treats the
* literal as an octal literal.
* @kind problem
* @problem.severity warning
* @precision low
* @id java/octal-literal
* @tags maintainability
* correctness
*/
import java
from IntegerLiteral lit, string val
where
lit.getLiteral() = val and
val.regexpMatch("0[0-7][0-7]+") and
lit.getParent() instanceof BinaryExpr and
not lit.getParent() instanceof Assignment and
not lit.getParent() instanceof BitwiseExpr and
not lit.getParent() instanceof ComparisonExpr
select lit, "Integer literal starts with 0."