Update assert-pure.ql now that the /pure directory has been removed

This commit is contained in:
Robert
2023-06-21 12:33:32 +01:00
parent 9903982bb1
commit 8559d3baa0

View File

@@ -2,9 +2,8 @@
* @name Unwanted dependency on vscode API
* @kind path-problem
* @problem.severity error
* @id vscode-codeql/assert-pure
* @description The modules stored under `pure` and tested in the `pure-tests`
* are intended to be "pure".
* @id vscode-codeql/assert-no-vscode-dependency
* @description The modules stored under `common` should not have dependencies on the VS Code API
*/
import javascript
@@ -13,12 +12,9 @@ class VSCodeImport extends ImportDeclaration {
VSCodeImport() { this.getImportedPath().getValue() = "vscode" }
}
class PureFile extends File {
PureFile() {
(
this.getRelativePath().regexpMatch(".*/src/pure/.*") or
this.getRelativePath().regexpMatch(".*/src/common/.*")
) and
class CommonFile extends File {
CommonFile() {
this.getRelativePath().regexpMatch(".*/src/common/.*") and
not this.getRelativePath().regexpMatch(".*/vscode/.*")
}
}
@@ -34,7 +30,8 @@ query predicate edges(AstNode a, AstNode b) {
from Module m, VSCodeImport v
where
m.getFile() instanceof PureFile and
m.getFile() instanceof CommonFile and
edges+(m, v)
select m, m, v,
"This module is not pure: it has a transitive dependency on the vscode API imported $@", v, "here"
"This module is in the 'common' directory but has a transitive dependency on the vscode API imported $@",
v, "here"