mirror of
https://github.com/github/codeql.git
synced 2026-04-25 16:55:19 +02:00
apply suggestions from code review
Co-Authored-By: Esben Sparre Andreasen <42067045+esben-semmle@users.noreply.github.com>
This commit is contained in:
committed by
Erik Krogh Kristensen
parent
1c424310ae
commit
666e11a506
@@ -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.
|
||||
|
||||
@@ -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()
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user