File tree Expand file tree Collapse file tree 3 files changed +8
-11
lines changed
javascript/ql/src/Statements Expand file tree Collapse file tree 3 files changed +8
-11
lines changed Original file line number Diff line number Diff line change 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
99is not an error in itself, but it is a pattern indicating that some
1010misunderstanding 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 >
2524In 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 .
2726However, 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 >
3534The 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 >
Original file line number Diff line number Diff line change 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
1515import Statements.UselessConditional
1616
1717predicate 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 ( ) )
Original file line number Diff line number Diff 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.
You can’t perform that action at this time.
0 commit comments