Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 666e11a

Browse files
erik-kroghEsben Sparre Andreasen
andcommitted
apply suggestions from code review
Co-Authored-By: Esben Sparre Andreasen <[email protected]>
1 parent 1c42431 commit 666e11a

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

javascript/ql/src/Statements/UseOfReturnlessFunction.qhelp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<qhelp>
55
<overview>
66
<p>
7-
JavaScript functions that do not return any value will implicitly return
7+
JavaScript functions that do not explicitly return a value will implicitly return
88
<code>undefined</code>. Using the return value from a function that never
99
explicitly return a value is not an error in itself, but it is a highly
1010
suspicious pattern indicating that some misunderstanding has occurred.

javascript/ql/src/Statements/UseOfReturnlessFunction.ql

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* @name Use of returnless function.
3-
* @description Using the return value of a function that does not return anything is highly suspicious.
3+
* @description Using the return value of a function that does not explicitly return is indicative of a mistake.
44
* @kind problem
55
* @problem.severity recommendation
66
* @id js/use-of-returnless-function
@@ -15,7 +15,7 @@ import Expressions.ExprHasNoEffect
1515
import Statements.UselessConditional
1616

1717
predicate returnsVoid(Function f) {
18-
exists(f.getBody().(Stmt)) and
18+
f.getBody() instanceof Stmt and
1919
not f instanceof ExternalDecl and
2020
not f.isGenerator() and
2121
not f.isAsync() and
@@ -40,7 +40,7 @@ predicate benignContext(Expr e) {
4040
or
4141
exists(SeqExpr seq, int i, int n | e = seq.getOperand(i) and n = seq.getNumOperands() |
4242
i < n - 1 or benignContext(seq)
43-
)
43+
exists(SeqExpr seq | seq.getLastOperand() = e and benignContext(seq))
4444
or
4545
exists(Expr parent | parent.getUnderlyingValue() = e and benignContext(parent))
4646
or
@@ -100,4 +100,4 @@ where
100100
not callBlacklist(call)
101101
select
102102
call, "the function $@ does not return anything, yet the return value is used.", call.getACallee(), call.getCalleeName()
103-
103+

0 commit comments

Comments
 (0)