-
Notifications
You must be signed in to change notification settings - Fork 2k
Expand file tree
/
Copy pathDBTypeInNonLib.ql
More file actions
27 lines (24 loc) · 1.02 KB
/
DBTypeInNonLib.ql
File metadata and controls
27 lines (24 loc) · 1.02 KB
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 Use of database type outside the language core
* @description Database types should only be used in the language core, abstractions should be used elsewhere.
* @kind problem
* @problem.severity warning
* @id ql/db-type-outside-core
* @tags maintainability
* @precision very-high
*/
import ql
/** Gets a folder that may contain raw DB types. */
string folderWithDbTypes() { result = ["lib", "downgrades", "upgrades"] }
from TypeExpr te
where
te.isDBType() and
not te.getLocation().getFile().getAbsolutePath().matches("%/" + folderWithDbTypes() + "/%") and
exists(File f | f.getAbsolutePath().matches("%/lib/%")) and
// it is needed in one case.
not te = any(Class c | c.getName() = "SuppressionScope").getASuperType() and
// QL-for-QL only has a src/ folder.
not te.getLocation().getFile().getAbsolutePath().matches("%/ql/ql/%") and
// tests are allowed to use DB types.
not te.getLocation().getFile().getAbsolutePath().matches("%/test/%")
select te, "Database type used outside the language lib/ folder."