Make river-crossing example comply with the CodeQL style guide

This commit is contained in:
Chris Smowton 2022-12-08 12:33:42 +00:00 коммит произвёл GitHub
Родитель 81110b19e7
Коммит 8789dfb655
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
3 изменённых файлов: 6 добавлений и 6 удалений

Просмотреть файл

@ -13,7 +13,7 @@ class Cargo extends string {
}
}
/** One of two shores. */
/** A shore, named either `Left` or `Right`. */
class Shore extends string {
Shore() {
this = "Left" or
@ -93,7 +93,7 @@ class Cargo extends string {
// Reachable by first following pathSoFar and then ferrying cargo
exists(string pathSoFar, string visitedStatesSoFar, Cargo cargo |
result = this.reachesVia(pathSoFar, visitedStatesSoFar).safeFerry(cargo) and
not exists(int i | i = visitedStatesSoFar.indexOf(result)) and // resulting state is not visited yet
not exists(visitedStatesSoFar.indexOf(result)) and // resulting state is not visited yet
visitedStates = visitedStatesSoFar + "_" + result and
path = pathSoFar + ",\nthen " + cargo + " is ferried " + result.towards()
)

Просмотреть файл

@ -154,7 +154,7 @@ class Shore extends string {
State reachesVia(string path) {
exists(string pathSoFar |
result = this.reachesVia(pathSoFar).transition() and
not exists(int i | i = pathSoFar.indexOf(result.toString())) and
not exists(pathSoFar.indexOf(result.toString())) and
path = pathSoFar + "\n↓\n" + result
)
}
@ -169,7 +169,7 @@ class Shore extends string {
}
override State reachesVia(string path) {
path = this + "\n↓\n" + result and result = transition()
path = this + "\n↓\n" + result and result = this.transition()
or
result = super.reachesVia(path)
}

Просмотреть файл

@ -118,7 +118,7 @@ class State extends TState {
State reachesVia(string path) {
exists(string pathSoFar |
result = this.reachesVia(pathSoFar).transition() and
not exists(int i | i = pathSoFar.indexOf(result.toString())) and
not exists(pathSoFar.indexOf(result.toString())) and
path = pathSoFar + "\n" + result
)
}
@ -133,7 +133,7 @@ class InitialState extends State {
}
override State reachesVia(string path) {
path = this + "\n" + result and result = transition()
path = this + "\n" + result and result = this.transition()
or
result = super.reachesVia(path)
}