89 lines
2.1 KiB
Plaintext
89 lines
2.1 KiB
Plaintext
=== deprecates: S1538
|
|
|
|
=== is duplicated by: S894
|
|
|
|
=== is duplicated by: S901
|
|
|
|
=== relates to: S902
|
|
|
|
=== relates to: S897
|
|
|
|
=== relates to: S905
|
|
|
|
=== relates to: S1029
|
|
|
|
=== relates to: S1116
|
|
|
|
=== relates to: S1172
|
|
|
|
=== relates to: S1751
|
|
|
|
=== relates to: S1854
|
|
|
|
=== relates to: S1862
|
|
|
|
=== relates to: S1879
|
|
|
|
=== relates to: S5918
|
|
|
|
=== relates to: S1475
|
|
|
|
=== on 25 Jun 2014, 10:10:31 Evgeny Mandrikov wrote:
|
|
Not applicable for Java - JLS7 14.21. Unreachable Statements:
|
|
|
|
____
|
|
It is a compile-time error if a statement cannot be executed because it is unreachable.
|
|
|
|
____
|
|
|
|
=== on 2 Feb 2015, 14:28:04 Freddy Mallet wrote:
|
|
@Ann, I would link this rule to CWE-561: \http://cwe.mitre.org/data/definitions/561.html and would slightly update the issue message :
|
|
|
|
|
|
"Remove the unreachable code after this "XXX" statement."
|
|
|
|
=== on 2 Feb 2015, 14:55:13 Ann Campbell wrote:
|
|
I added the reference, but I didn't update the message. The addition of the modifier "unreachable" implies that there is reachable code after the jump statement & there's not; it's all unreachable.
|
|
|
|
=== on 3 Nov 2020, 14:55:21 Nicolas Harraudeau wrote:
|
|
Note that this rule has different implementations and ways to highlight code.
|
|
|
|
|
|
New analyzers should have their primary location on the first line of dead code so that the location doesn't change if/when a CFG is added later on.
|
|
|
|
|
|
=== SLANG [go/kotlin/scala/ruby/apex] and swift
|
|
|
|
The rule detects simple cases where a single return/throw/... is followed by dead code.
|
|
|
|
|
|
Primary location on the return/throw/... statement exiting the flow.
|
|
|
|
|
|
=== Python/PHP
|
|
|
|
This is the preferred way as it detects more issues, but it requires a CFG.
|
|
|
|
|
|
The rule is able to detect complex cases where multiple branches exit before the dead code is reached. Example: dead code after an ``++if-else++`` block which has a ``++return++`` in each branch.
|
|
|
|
|
|
Primary location on the first line of dead code.
|
|
|
|
Secondaries on every statement exiting the code block.
|
|
|
|
|
|
=== TSQL
|
|
|
|
The rule detects simple cases where a single return/throw/... is followed by dead code.
|
|
|
|
Primary location on the first line of dead code.
|
|
|
|
|
|
=== CFamily
|
|
|
|
it is based on CLANG and detects far more use cases of dead code.
|
|
|
|
|
|
|