Skip to content

Commit 8789dfb

Browse files
authored
Make river-crossing example comply with the CodeQL style guide
1 parent 81110b1 commit 8789dfb

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

docs/codeql/writing-codeql-queries/river-answer-1-path.ql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class Cargo extends string {
1313
}
1414
}
1515

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

docs/codeql/writing-codeql-queries/river-answer-2-abstract-class.ql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ class Shore extends string {
154154
State reachesVia(string path) {
155155
exists(string pathSoFar |
156156
result = this.reachesVia(pathSoFar).transition() and
157-
not exists(int i | i = pathSoFar.indexOf(result.toString())) and
157+
not exists(pathSoFar.indexOf(result.toString())) and
158158
path = pathSoFar + "\n↓\n" + result
159159
)
160160
}
@@ -169,7 +169,7 @@ class Shore extends string {
169169
}
170170

171171
override State reachesVia(string path) {
172-
path = this + "\n↓\n" + result and result = transition()
172+
path = this + "\n↓\n" + result and result = this.transition()
173173
or
174174
result = super.reachesVia(path)
175175
}

docs/codeql/writing-codeql-queries/river-answer-3-datatypes.ql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ class State extends TState {
118118
State reachesVia(string path) {
119119
exists(string pathSoFar |
120120
result = this.reachesVia(pathSoFar).transition() and
121-
not exists(int i | i = pathSoFar.indexOf(result.toString())) and
121+
not exists(pathSoFar.indexOf(result.toString())) and
122122
path = pathSoFar + "\n" + result
123123
)
124124
}
@@ -133,7 +133,7 @@ class InitialState extends State {
133133
}
134134

135135
override State reachesVia(string path) {
136-
path = this + "\n" + result and result = transition()
136+
path = this + "\n" + result and result = this.transition()
137137
or
138138
result = super.reachesVia(path)
139139
}

0 commit comments

Comments
 (0)