Skip to content

Commit 327e0da

Browse files
authored
Merge pull request #7674 from erik-krogh/dbTypeInNonLib
QL: Use of db-type outside language core.
2 parents 36e02ae + 548fb47 commit 327e0da

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/**
2+
* @name Use of database type outside the language core
3+
* @description Database types should only be used in the language core, abstractions should be used elsewhere.
4+
* @kind problem
5+
* @problem.severity warning
6+
* @id ql/db-type-outside-core
7+
* @tags maintainability
8+
* @precision very-high
9+
*/
10+
11+
import ql
12+
13+
from TypeExpr te
14+
where
15+
te.isDBType() and
16+
not te.getLocation().getFile().getAbsolutePath().matches("%/lib/%") and
17+
exists(File f | f.getAbsolutePath().matches("%/lib/%")) and
18+
// it is needed in one case.
19+
not te = any(Class c | c.getName() = "SuppressionScope").getASuperType() and
20+
// QL-for-QL only has a src/ folder.
21+
not te.getLocation().getFile().getAbsolutePath().matches("%/ql/ql/%") and
22+
// tests are allowed to use DB types.
23+
not te.getLocation().getFile().getAbsolutePath().matches("%/test/%")
24+
select te, "Database type used outside the language lib/ folder."

0 commit comments

Comments
 (0)