Skip to content

Commit e5fc419

Browse files
committed
Make test pass
1 parent e3fb7f8 commit e5fc419

3 files changed

Lines changed: 8 additions & 6 deletions

File tree

‎go/ql/src/RedundantCode/UnreachableStatement.ql‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,13 @@ predicate allowlist(Stmt s) {
101101
}
102102

103103
Stmt firstNonAllowlisted(Stmt s) {
104-
not allowlist(s) and result = s
105-
or
106-
allowlist(s) and
107-
exists(Stmt next | getPreviousStmt(next) = s | result = firstNonAllowlisted(next))
104+
not isReachable(s) and
105+
(
106+
not allowlist(s) and result = s
107+
or
108+
allowlist(s) and
109+
exists(Stmt next | getPreviousStmt(next) = s | result = firstNonAllowlisted(next))
110+
)
108111
}
109112

110113
/** Holds if `s` is the first non-allowlisted statement in a run of unreachable statements. */

‎go/ql/test/query-tests/RedundantCode/UnreachableStatement/UnreachableStatement.expected‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,3 @@
1111
| main.go:153:2:153:22 | return statement | This statement is unreachable. |
1212
| main.go:159:2:159:43 | return statement | This statement is unreachable. |
1313
| main.go:171:2:171:14 | expression statement | This statement is unreachable. |
14-
| main.go:177:1:178:12 | labeled statement | This statement is unreachable. |

‎go/ql/test/query-tests/RedundantCode/UnreachableStatement/main.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ func test22() {
175175
goto reachableLabel
176176
panic("unreachable") // OK: allowlisted statement
177177
reachableLabel:
178-
reachable() // $ SPURIOUS: Alert // OK: reachable through the goto
178+
reachable() // OK: reachable through the goto
179179
}
180180

181181
func test23() {

0 commit comments

Comments
 (0)