apply suggestions from code review

Co-Authored-By: Esben Sparre Andreasen <42067045+esben-semmle@users.noreply.github.com>
This commit is contained in:
Erik Krogh Kristensen
2019-10-03 16:09:53 +02:00
committed by Erik Krogh Kristensen
parent 1c424310ae
commit 666e11a506
2 changed files with 5 additions and 5 deletions

View File

@@ -4,7 +4,7 @@
<qhelp>
<overview>
<p>
JavaScript functions that do not return any value will implicitly return
JavaScript functions that do not explicitly return a value will implicitly return
<code>undefined</code>. Using the return value from a function that never
explicitly return a value is not an error in itself, but it is a highly
suspicious pattern indicating that some misunderstanding has occurred.

View File

@@ -1,6 +1,6 @@
/**
* @name Use of returnless function.
* @description Using the return value of a function that does not return anything is highly suspicious.
* @description Using the return value of a function that does not explicitly return is indicative of a mistake.
* @kind problem
* @problem.severity recommendation
* @id js/use-of-returnless-function
@@ -15,7 +15,7 @@ import Expressions.ExprHasNoEffect
import Statements.UselessConditional
predicate returnsVoid(Function f) {
exists(f.getBody().(Stmt)) and
f.getBody() instanceof Stmt and
not f instanceof ExternalDecl and
not f.isGenerator() and
not f.isAsync() and
@@ -40,7 +40,7 @@ predicate benignContext(Expr e) {
or
exists(SeqExpr seq, int i, int n | e = seq.getOperand(i) and n = seq.getNumOperands() |
i < n - 1 or benignContext(seq)
)
exists(SeqExpr seq | seq.getLastOperand() = e and benignContext(seq))
or
exists(Expr parent | parent.getUnderlyingValue() = e and benignContext(parent))
or
@@ -100,4 +100,4 @@ where
not callBlacklist(call)
select
call, "the function $@ does not return anything, yet the return value is used.", call.getACallee(), call.getCalleeName()