Why ReSharper Is Worth Using (reason #879)

Posted by Peter Kellner on April 14, 2013 · 1 min read

 

I often email the folks at JetBrains (the makers of ReSharper) letting them know that one of their refactors is wrong.  They often email me back letting me know my about my misunderstanding.  I actually enjoy this.

Today, was a perfect example but I did not get past the ReSharper feedback form when I realized my code was wrong (sadly missed the exchange with them).  I’m busy writing the SEO save for Silicon Valley Code Camp’s new web site (coming by next week hopefully).  In this case, I’m looking for a trackId passed into the sessions.aspx page. If I find it, then I redirect to a more friendly URL.

Here is my code I was going to complain to ReSharper about as incorrectly warning me that my trackId = –1; is redundant.

image

SNAGHTML40a7f61

My mistake is that trackId is always replaced (even with 0) if the QueryString does not evaluate to a valid int.

The corrected code is this:

image

One less bug thanks to ReSharper.