C#

C#

Made by DeepSource

Unreachable code detected CS-W1016

Bug risk
Major
Autofix

Statements placed after the return statement are not executed and is considered as "dead" code. Either adding the return statement was a mistake or that the code placed after the return statement wasn't supposed to be there in the first place. Either way, it is recommended that you rectify this immediately.

Bad Practice

foreach (var item in items)
{
    // ...
    return;

    // ...
}

Recommended

foreach (var item in items)
{
    // ...
    if (!ShouldPick(item))
        return;

    // ...
}