File tree Expand file tree Collapse file tree
test/query-tests/RedundantCode/UnreachableStatement Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -101,10 +101,13 @@ predicate allowlist(Stmt s) {
101101}
102102
103103Stmt 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. */
Original file line number Diff line number Diff line change 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. |
Original file line number Diff line number Diff line change @@ -175,7 +175,7 @@ func test22() {
175175 goto reachableLabel
176176 panic ("unreachable" ) // OK: allowlisted statement
177177reachableLabel:
178- reachable () // $ SPURIOUS: Alert // OK: reachable through the goto
178+ reachable () // OK: reachable through the goto
179179}
180180
181181func test23 () {
You can’t perform that action at this time.
0 commit comments