Skip to content

Commit 6f5ac5d

Browse files
Introduce getAUse
1 parent 4c880df commit 6f5ac5d

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,12 @@
2626
/**
2727
* In how many ways is this command used. Will always be at least 1.
2828
*/
29-
int getNumberOfUsages() { result = count(CommandUsage e | e.getCommandName() = this | e) }
29+
int getNumberOfUsages() { result = count(this.getAUse()) }
30+
31+
/**
32+
* Get a usage of this command.
33+
*/
34+
CommandUsage getAUse() { result.getCommandName() = this }
3035

3136
/**
3237
* Get the canonical first usage of this command, to use for the location
@@ -35,10 +40,7 @@
3540
* the alert.
3641
*/
3742
CommandUsage getFirstUsage() {
38-
result.getCommandName() = this and
39-
forall(CommandUsage e | e.getCommandName() = this |
40-
e.getLocationOrdinal() >= result.getLocationOrdinal()
41-
)
43+
result = max(CommandUsage use | use = this.getAUse() | use order by use.getLocationOrdinal())
4244
}
4345
}
4446

0 commit comments

Comments
 (0)