Merge pull request #2533 from github/robertbrignull/assert-pure

Update assert-pure.ql now that the /pure directory has been removed
This commit is contained in:
Robert
2023-06-22 15:19:25 +01:00
committed by GitHub

View File

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