This Question is Not Answered

1 "correct" answer available (4 pts) 2 "helpful" answers available (2 pts)
0 Replies Last post: Mar 20, 2014 10:33 PM by Wesley Fang  
Wesley  Fang Newbie 6 posts since
Feb 20, 2014
Currently Being Moderated

Mar 20, 2014 10:33 PM

Strange logic refactor

Hey, I found a strange logic refactor when I cleaned a method in 8.2 EAP.

The original method is

 

Code:
// Put your code here and then press the button
//
private bool ValidateCheques()
{
    bool valid = true;
          
    if(!cntCheques.Validate() && rblDepositOptionList.SelectedIndex == (int)Constants.eDepositType.DepositProvided)
    {
     valid = false;
    }
               
    if(chkCancelClientFile.Checked)
    {
     valid = true;
    }

    return valid;
}

 

After resharper I got this:

 

Code:
private bool ValidateCheques()
{
    bool valid = cntCheques.Validate() && rblDepositOptionList.SelectedIndex == (int)Constants.eDepositType.DepositProvided || chkCancelClientFile.Checked;

    return valid;
}

 

However I really think the answer is

 

Code:
private bool ValidateCheques()
{
    bool valid = cntCheques.Validate() || rblDepositOptionList.SelectedIndex != (int)Constants.eDepositType.DepositProvided || chkCancelClientFile.Checked;

    return valid;
}

 

I've attached the entire refactor record. Please let me know if it is a bug. Thanks.

 

FYI: JetBrains ReSharper 8.2 EAP Full Edition Build 8.2.0.1583 on 2014-03-13T14:24:04

Attachments:

More Like This

  • Retrieving data ...