Skip to content

Commit ead1869

Browse files
Use PackageJson class
1 parent 70ae728 commit ead1869

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

.github/codeql/queries/unique-command-use.ql

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,9 @@
4242

4343
class CommandUsagePackageJsonMenuItem extends CommandUsage, JsonObject {
4444
CommandUsagePackageJsonMenuItem() {
45-
this.getFile().getBaseName() = "package.json" and
4645
exists(this.getPropValue("command")) and
47-
exists(JsonObject topObject, string menuName |
48-
not exists(topObject.getParent()) and
49-
topObject
46+
exists(PackageJson packageJson, string menuName |
47+
packageJson
5048
.getPropValue("contributes")
5149
.getPropValue("menus")
5250
.getPropValue(menuName)
@@ -59,9 +57,8 @@
5957
}
6058

6159
predicate isDisabledInCommandPalette(string commandName) {
62-
exists(JsonObject topObject, JsonObject commandPaletteObject |
63-
not exists(topObject.getParent()) and
64-
topObject
60+
exists(PackageJson packageJson, JsonObject commandPaletteObject |
61+
packageJson
6562
.getPropValue("contributes")
6663
.getPropValue("menus")
6764
.getPropValue("commandPalette")
@@ -75,9 +72,8 @@
7572
CommandUsagePackageJsonCommandPalette() {
7673
this.getFile().getBaseName() = "package.json" and
7774
exists(this.getPropValue("command")) and
78-
exists(JsonObject topObject |
79-
not exists(topObject.getParent()) and
80-
topObject.getPropValue("contributes").getPropValue("commands").getElementValue(_) = this
75+
exists(PackageJson packageJson |
76+
packageJson.getPropValue("contributes").getPropValue("commands").getElementValue(_) = this
8177
) and
8278
not isDisabledInCommandPalette(this.getPropValue("command").getStringValue())
8379
}

0 commit comments

Comments
 (0)