Merge pull request #7674 from erik-krogh/dbTypeInNonLib

QL: Use of db-type outside language core.
This commit is contained in:
Taus
2022-02-11 12:00:14 +01:00
committed by GitHub
2 changed files with 24 additions and 0 deletions

View File

@@ -0,0 +1,24 @@
/**
* @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
from TypeExpr te
where
te.isDBType() and
not te.getLocation().getFile().getAbsolutePath().matches("%/lib/%") 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."