mirror of
https://github.com/github/codeql.git
synced 2026-05-03 12:45:27 +02:00
QL code and tests for C#/C++/JavaScript.
This commit is contained in:
43
javascript/ql/src/Statements/UnreachableStatement.qhelp
Normal file
43
javascript/ql/src/Statements/UnreachableStatement.qhelp
Normal file
@@ -0,0 +1,43 @@
|
||||
<!DOCTYPE qhelp PUBLIC
|
||||
"-//Semmle//qhelp//EN"
|
||||
"qhelp.dtd">
|
||||
<qhelp>
|
||||
<overview>
|
||||
<p>
|
||||
An unreachable statement almost always indicates missing code or a latent bug and should be examined
|
||||
carefully.
|
||||
</p>
|
||||
|
||||
</overview>
|
||||
<recommendation>
|
||||
|
||||
<p>
|
||||
Examine the surrounding code to determine why the statement has become unreachable. If it is no
|
||||
longer needed, remove the statement.
|
||||
</p>
|
||||
|
||||
</recommendation>
|
||||
<example>
|
||||
|
||||
<p>
|
||||
In the following example, a spurious semicolon after the <code>if</code> condition at line 2 makes
|
||||
the <code>return</code> statement on line 4 unreachable: the function will always execute the
|
||||
<code>return</code> statement on line 3 first, so it will never reach line 4.
|
||||
</p>
|
||||
|
||||
<sample src="examples/UnreachableStatement.js" />
|
||||
|
||||
<p>
|
||||
To correct this issue, remove the spurious semicolon:
|
||||
</p>
|
||||
|
||||
<sample src="examples/UnreachableStatementGood.js" />
|
||||
|
||||
</example>
|
||||
<references>
|
||||
|
||||
|
||||
<li>Wikipedia: <a href="http://en.wikipedia.org/wiki/Unreachable_code">Unreachable code</a>.</li>
|
||||
|
||||
</references>
|
||||
</qhelp>
|
||||
Reference in New Issue
Block a user