History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: RSRP-59763
Type: Bug Bug
Status: Open Open
Priority: Major Major
Assignee: Alexander Zverev
Reporter: Matt Eland
Votes: 0
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
ReSharper

Invert if to reduce nesting context action is NOT reducing nesting in some cases

Created: 28 Feb 08 20:59   Updated: 06 May 08 18:56
Component/s: Generate Action
Fix Version/s: 4.0
Security Level: Everybody (All jira users)

Original Estimate: Unknown Remaining Estimate: Unknown Time Spent: Unknown

Build: 740


 Description  « Hide
Given the following:
private static void MyMethod(MyClass1 searcher, MyClass2 oldItem)
        {
            if (oldItem != null && searcher != null)
            {
                try
                {
                    // Some operation
                }
                catch (Exception e)
                {
                    // Some logging code
                }
            }
        }

When I do the suggested invert if to remove nesting, it generates the following:

if (oldItem == null || searcher == null)
            {
            }
            else
            {
                try
                {
                    // My operation
                }
                catch (Exception e)
                {
                    // My logging
                }
            }

when it should generate:

if (oldItem == null || searcher == null)
                 return;
            try
            {
                 // My operation
            }
           catch (Exception e)
            {
                 // My logging
            }


 All   Comments   Work Log   Change History      Sort Order:
Matt Eland - 28 Feb 08 20:59
My bad. Misnamed the issue. Should be... is NOT reducing nesting in some cases