Quantcast
Channel: YouTrackReSharper (RSRP) - Bug and Issue Tracker
Viewing all articles
Browse latest Browse all 106942

RSRP-289961: Bug in analysis of "Redundant control flow jump statement

$
0
0
Reporter Simon (simonl1980) Simon (simonl1980)
Created Mar 13, 2012 7:28:54 PM
Updated Mar 13, 2012 7:28:54 PM
Priority Normal
Type Bug
Fix versions No Fix versions
State Submitted
Assignee Evgeny Pasynkov (pasynkov)
Subsystem Code Analysis - Control Flow
Affected versions 6.1, 6.1.1
Fixed in build No Fixed in build
Using the following code in a console app:

using System;
namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            if (args.Length == 1)
            {
                Console.WriteLine("1");
                return;  //****This return is flagged as not required
            }
            new ClassTwo().AnotherMethod();
        }
    }

    public class ClassTwo
    {
        public void AnotherMethod()
        {
            Console.WriteLine("2");
        }
    }
}


JetBrains ReSharper 6.1 Full Edition (Build 6.1.1000.82 on 2012-02-15T16:14:48) incorrectly marks the return statement as redundant. However, if I then apply the 'Inline Method' refactoring to ClassTwo.AnotherMethod(), then the return ISN'T marked as redundant, despite the fact that the code is functionally equivalent.

Without the return though, the extra Console.WriteLine() is executed, changing the program flow.

Viewing all articles
Browse latest Browse all 106942

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>