Project
ReSharper
Priority
Major
Type
Bug
Fix versions
4.5.3
State
Fixed
Assignee
eugene legkiy
Subsystem
Generate
Affected versions
No Affected versions
Fixed in build
5.0.1640.7  
  • Created by   Matt Eland
    4 years ago (28 Feb 2008 21:59)
  • Updated by   eugene legkiy
    2 years ago (15 Mar 2010 18:51)
  • Jira: RSRP-59763
    (history, comments)
 
RSRP-59763 Invert if to reduce nesting context action is NOT reducing nesting in some cases
0
Issue is visible to: All Users
  The issue is visible to the selected user group only
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
            }
Comments (1)
 
History
 
Linked Issues (?)
 
TeamCity Changes (1)
 
Matt Eland
  Matt Eland
28 Feb 2008 21:59
4 years ago
My bad. Misnamed the issue. Should be... is NOT reducing nesting in some cases