Incorrect Redundant check before assignment

Hi

In the following code:

 

private void SetCategoryIdSelectedItem(HlpAccountCode value)
        {
            if (value == null) return;

            if (base.CategoryIdSelectedItem != value.HlpAccountGroup.CategoryID)
                base.CategoryIdSelectedItem = value.HlpAccountGroup.CategoryID;
        }


I'm getting an "incorrect redundant check before assignment" for the line if(base.CategoryIdSelectedItem != value.HlpAccountGroup.CategoryID).

This is wrong - the two values can quite easily be different (CategoryIdSelectedItem and CategoryID are both enums)

Regards
Jeremy
2 comments
Comment actions Permalink

Hello Jeremy,

Thank you for reporting this issue! It has already been logged in our bug-tracker
as http://youtrack.jetbrains.net/issue/RSRP-175600. You're welcome to vote
for it.

Andrey Serebryansky
Support Engineer
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"

Hi

In the following code:

private void SetCategoryIdSelectedItem(HlpAccountCode value)
{
if (value == null) return;
if (base.CategoryIdSelectedItem !=
value.HlpAccountGroup.CategoryID)
base.CategoryIdSelectedItem =
value.HlpAccountGroup.CategoryID;
}
I'm getting an "incorrect redundant check before assignment" for the
line if(base.CategoryIdSelectedItem !=
value.HlpAccountGroup.CategoryID).

This is wrong - the two values can quite easily be different
(CategoryIdSelectedItem and CategoryID are both enums)

Regards
Jeremy
---
Original message URL:
http://devnet.jetbrains.net/message/5266890#5266890



0
Comment actions Permalink

This is still an issue as of 2013-12-12 using ReSharper 7.1.3.

One of my fellow developers was about to mark the Peer Review of my code as failed until I pointed out that this 3+ year old bug is what is causing the erroneous suggestion by ReSharper.

Please fix this.  Soon.

0

Please sign in to leave a comment.