mirror of
https://github.com/github/codeql.git
synced 2025-12-17 01:03:14 +01:00
Merge pull request #7674 from erik-krogh/dbTypeInNonLib
QL: Use of db-type outside language core.
This commit is contained in:
24
ql/ql/src/queries/style/DBTypeInNonLib.ql
Normal file
24
ql/ql/src/queries/style/DBTypeInNonLib.ql
Normal 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."
|
||||
Reference in New Issue
Block a user