0

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



Attachment(s):
Record.zip

0 comments

Please sign in to leave a comment.