Skip to content

Commit ad3185c

Browse files
committed
simplify lastStatementHasNoEffect and use the control-flow to determine which statement is the last
1 parent db22916 commit ad3185c

1 file changed

Lines changed: 1 addition & 5 deletions

File tree

javascript/ql/src/Statements/UseOfReturnlessFunction.ql

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,7 @@ predicate alwaysThrows(Function f) {
8686
* Holds if the last statement in the function is flagged by the js/useless-expression query.
8787
*/
8888
predicate lastStatementHasNoEffect(Function f) {
89-
exists(DataFlow::Node noEffect |
90-
noEffect.getContainer() = f and
91-
hasNoEffect(noEffect.asExpr()) and
92-
not exists(noEffect.getASuccessor())
93-
)
89+
hasNoEffect(f.getExit().getAPredecessor())
9490
}
9591

9692
predicate callToVoidFunction(DataFlow::CallNode call, Function func) {

0 commit comments

Comments
 (0)