зеркало из https://github.com/github/codeql.git
Make river-crossing example comply with the CodeQL style guide
This commit is contained in:
Родитель
81110b19e7
Коммит
8789dfb655
|
@ -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)
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче