Refactor! Pro and SA1503

I’m busy as blood-engorged zombie locusts tearing into each other until one standsatop the heap like Jet Li in The One. I’ve been fixing my code files one by one toconform to the rules in StyleCop.Luckily I have Refactor! Pro from Developer Express.

StyleCop rule SA1503 is that “The body of the if statement must be wrapped in openingand closing curly brackets. The following is a no-no:


if (isTrue)doAnAction();

Instead, write:


if (isTrue){ doAnAction(); }

or:

if (isTrue){ doAnAction(); }

Is it anal? Sure. But that’s what code style is all about. Making your code look thesame so that your eye flows across it smoothly and quickly. Meaning should be standard.Beating a different drum doesn’t mean you can’t keep in lock-step. At least with yourself.

The cool part is that Refactor! Pro makes this a three-keypress action. Place thecursor right after the if statement and before the “doAnAction”. Press the R!P key.Press Enter.

You just used the “Add Block Delimiters” action, and bam! Perfect code.

Now if I just need to find (or create) the actions to put proper white space aftermy code blocks, use “this.” before accessing an field, and alphabetize my “using”statements. I think it’s too much to ask that an inexpensive developer tool get ridof the zombie locusts.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s