Internal queries: Replace deprecated predicates

This commit is contained in:
Henry Mercer 2024-01-24 00:20:18 +00:00
parent d43ae36a63
commit 666e2f9edf
2 changed files with 10 additions and 21 deletions

View file

@ -19,7 +19,7 @@ class ActionDeclaration extends File {
getRelativePath().matches("%/action.yml") getRelativePath().matches("%/action.yml")
} }
YAMLDocument getRootNode() { YamlDocument getRootNode() {
result.getFile() = this result.getFile() = this
} }
@ -27,7 +27,7 @@ class ActionDeclaration extends File {
* The name of any input to this action. * The name of any input to this action.
*/ */
string getAnInput() { string getAnInput() {
result = getRootNode().(YAMLMapping).lookup("inputs").(YAMLMapping).getKey(_).(YAMLString).getValue() result = getRootNode().(YamlMapping).lookup("inputs").(YamlMapping).getKey(_).(YamlString).getValue()
} }
/** /**
@ -35,21 +35,10 @@ class ActionDeclaration extends File {
* or because it has a default value. * or because it has a default value.
*/ */
predicate inputAlwaysHasValue(string input) { predicate inputAlwaysHasValue(string input) {
exists(YAMLMapping value | exists(YamlMapping value |
value = getRootNode().(YAMLMapping).lookup("inputs").(YAMLMapping).lookup(input) and value = getRootNode().(YamlMapping).lookup("inputs").(YamlMapping).lookup(input) and
(exists(value.lookup("default")) or (exists(value.lookup("default")) or
value.lookup("required").(YAMLBool).getBoolValue() = true)) value.lookup("required").(YamlBool).getBoolValue() = true))
}
/**
* The function that is the entrypoint to this action.
*/
FunctionDeclStmt getEntrypoint() {
result.getFile().getRelativePath() = getRootNode().
(YAMLMapping).lookup("runs").
(YAMLMapping).lookup("main").
(YAMLString).getValue().regexpReplaceAll("\\.\\./lib/(.*)\\.js", "src/$1.ts") and
result.getName() = "run"
} }
} }

View file

@ -24,7 +24,7 @@ class ActionDeclaration extends File {
result = getRelativePath().regexpCapture("(.*)/action.yml", 1) result = getRelativePath().regexpCapture("(.*)/action.yml", 1)
} }
YAMLDocument getRootNode() { YamlDocument getRootNode() {
result.getFile() = this result.getFile() = this
} }
@ -32,7 +32,7 @@ class ActionDeclaration extends File {
* The name of any input to this action. * The name of any input to this action.
*/ */
string getAnInput() { string getAnInput() {
result = getRootNode().(YAMLMapping).lookup("inputs").(YAMLMapping).getKey(_).(YAMLString).getValue() result = getRootNode().(YamlMapping).lookup("inputs").(YamlMapping).getKey(_).(YamlString).getValue()
} }
/** /**
@ -40,9 +40,9 @@ class ActionDeclaration extends File {
*/ */
FunctionDeclStmt getEntrypoint() { FunctionDeclStmt getEntrypoint() {
result.getFile().getRelativePath() = getRootNode(). result.getFile().getRelativePath() = getRootNode().
(YAMLMapping).lookup("runs"). (YamlMapping).lookup("runs").
(YAMLMapping).lookup("main"). (YamlMapping).lookup("main").
(YAMLString).getValue().regexpReplaceAll("\\.\\./lib/(.*)\\.js", "src/$1.ts") and (YamlString).getValue().regexpReplaceAll("\\.\\./lib/(.*)\\.js", "src/$1.ts") and
result.getName() = "run" result.getName() = "run"
} }
} }