Skip to content

Commit bd67d8d

Browse files
authored
Merge pull request #2098 from github/henrymercer/update-internal-queries
Internal queries: Replace deprecated predicates
2 parents 65c7496 + a2619f6 commit bd67d8d

File tree

2 files changed

+10
-21
lines changed

2 files changed

+10
-21
lines changed

queries/required-action-input.ql

+5-16
Original file line numberDiff line numberDiff line change
@@ -19,37 +19,26 @@ class ActionDeclaration extends File {
1919
getRelativePath().matches("%/action.yml")
2020
}
2121

22-
YAMLDocument getRootNode() {
22+
YamlDocument getRootNode() {
2323
result.getFile() = this
2424
}
2525

2626
/**
2727
* The name of any input to this action.
2828
*/
2929
string getAnInput() {
30-
result = getRootNode().(YAMLMapping).lookup("inputs").(YAMLMapping).getKey(_).(YAMLString).getValue()
30+
result = getRootNode().(YamlMapping).lookup("inputs").(YamlMapping).getKey(_).(YamlString).getValue()
3131
}
3232

3333
/**
3434
* The given input always has a value, either because it is required,
3535
* or because it has a default value.
3636
*/
3737
predicate inputAlwaysHasValue(string input) {
38-
exists(YAMLMapping value |
39-
value = getRootNode().(YAMLMapping).lookup("inputs").(YAMLMapping).lookup(input) and
38+
exists(YamlMapping value |
39+
value = getRootNode().(YamlMapping).lookup("inputs").(YamlMapping).lookup(input) and
4040
(exists(value.lookup("default")) or
41-
value.lookup("required").(YAMLBool).getBoolValue() = true))
42-
}
43-
44-
/**
45-
* The function that is the entrypoint to this action.
46-
*/
47-
FunctionDeclStmt getEntrypoint() {
48-
result.getFile().getRelativePath() = getRootNode().
49-
(YAMLMapping).lookup("runs").
50-
(YAMLMapping).lookup("main").
51-
(YAMLString).getValue().regexpReplaceAll("\\.\\./lib/(.*)\\.js", "src/$1.ts") and
52-
result.getName() = "run"
41+
value.lookup("required").(YamlBool).getBoolValue() = true))
5342
}
5443
}
5544

queries/undeclared-action-input.ql

+5-5
Original file line numberDiff line numberDiff line change
@@ -24,25 +24,25 @@ class ActionDeclaration extends File {
2424
result = getRelativePath().regexpCapture("(.*)/action.yml", 1)
2525
}
2626

27-
YAMLDocument getRootNode() {
27+
YamlDocument getRootNode() {
2828
result.getFile() = this
2929
}
3030

3131
/**
3232
* The name of any input to this action.
3333
*/
3434
string getAnInput() {
35-
result = getRootNode().(YAMLMapping).lookup("inputs").(YAMLMapping).getKey(_).(YAMLString).getValue()
35+
result = getRootNode().(YamlMapping).lookup("inputs").(YamlMapping).getKey(_).(YamlString).getValue()
3636
}
3737

3838
/**
3939
* The function that is the entrypoint to this action.
4040
*/
4141
FunctionDeclStmt getEntrypoint() {
4242
result.getFile().getRelativePath() = getRootNode().
43-
(YAMLMapping).lookup("runs").
44-
(YAMLMapping).lookup("main").
45-
(YAMLString).getValue().regexpReplaceAll("\\.\\./lib/(.*)\\.js", "src/$1.ts") and
43+
(YamlMapping).lookup("runs").
44+
(YamlMapping).lookup("main").
45+
(YamlString).getValue().regexpReplaceAll("\\.\\./lib/(.*)\\.js", "src/$1.ts") and
4646
result.getName() = "run"
4747
}
4848
}

0 commit comments

Comments
 (0)