Skip to content

Commit c6918ef

Browse files
committed
changes to documentation and small change in returnsVoid based on code-review
1 parent 8c7f316 commit c6918ef

File tree

3 files changed

+8
-11
lines changed

3 files changed

+8
-11
lines changed

javascript/ql/src/Statements/UseOfReturnlessFunction.qhelp

Lines changed: 6 additions & 7 deletions
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 return an expression will implicitly return
88
<code>undefined</code>. Using the implicit return value from such a function
99
is not an error in itself, but it is a pattern indicating that some
1010
misunderstanding has occurred.
@@ -14,27 +14,26 @@ misunderstanding has occurred.
1414
<recommendation>
1515

1616
<p>
17-
Do not use the return value from a function that does not explicitly return
18-
a value.
17+
Do not use the return value from a function that does not return an expression.
1918
</p>
2019

2120
</recommendation>
2221
<example>
2322

2423
<p>
2524
In the example below, the function <code>renderText</code> is used to render
26-
text through side effects, and the function does not return a value.
25+
text through side effects, and the function does not return an expression.
2726
However, the programmer still uses the return value from
28-
<code>renderText</code> as if the function returned a value, which is clearly
29-
an error.
27+
<code>renderText</code> as if the function returned an expression, which is
28+
clearly an error.
3029
</p>
3130

3231
<sample src="examples/UseOfReturnlessFunction.js" />
3332

3433
<p>
3534
The program can be fixed either removing the use of the value returned by
3635
<code>renderText</code>, or by changing the <code>renderText</code> method
37-
to return a value.
36+
to return an expression.
3837
</p>
3938

4039
</example>

javascript/ql/src/Statements/UseOfReturnlessFunction.ql

Lines changed: 2 additions & 2 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 explicitly return is indicative of a mistake.
3+
* @description Using the return value of a function that does not return an expression is indicative of a mistake.
44
* @kind problem
55
* @problem.severity warning
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-
f.getBody() instanceof Stmt and
18+
not f instanceof ArrowFunctionExpr and
1919
not f.isGenerator() and
2020
not f.isAsync() and
2121
not exists(f.getAReturnedExpr())

javascript/ql/src/Statements/UselessConditional.ql

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,6 @@ predicate whitelist(Expr e) {
124124
isConstantBooleanReturnValue(e)
125125
}
126126

127-
128-
129127
/**
130128
* Holds if `e` is part of a conditional node `cond` that evaluates
131129
* `e` and checks its value for truthiness.

0 commit comments

Comments
 (0)