Our C++ coding standard requires redundant block delimiters for if-then-else, switch and try-catch statements. Makes the code look consistent and avoids a number of potential gotchas. Refactor Pro will not allow a case to conditional refactoring unless the redundant block delimiters are removed. Same for conditional to case.
Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.
Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.
Hi Mike,
Thank you for the suggestion.
However, we're unable to reproduce the situation you described locally. Can you please provide us with step-by-step instructions on how to reproduce this problem, or better yet, post here a small sample, illustrating it?
Thanks,
Vito
Refactor Pro will not allow a case to conditional refactoring of this legal C++ statement which is structured with additional delimiters to comply with our C++ coding standard:
switch (Mode)
{
case CPowerMeter::e_Software:
{
// Set PM's offset to 0.0.
Offset_dB(0.0, true);
break;
}
default:
{
assert(false); // Only software PM offsets supported right now.
}
}
It reports "no operations are available. Yet if I refactor out redundant delimiters to this:
switch (Mode)
{
case CPowerMeter::e_Software:
// Set PM's offset to 0.0.
Offset_dB(0.0, true);
break;
default:
assert(false); // Only software PM offsets supported right now.
}
This CAN be refactored to:
if (Mode == CPowerMeter::e_Software)
// Set PM's offset to 0.0.
Offset_dB(0.0, true);
else
assert(0); // Only software PM offsets supported right now.
To which Refactor Pro will let me add redundant delimiters to the 1st code block but not the 2nd:
if (Mode == CPowerMeter::e_Software)
{
// Set PM's offset to 0.0.
Offset_dB(0.0, true);
}
else
assert(0); // Only software PM offsets supported right now.
After adding redundant delimiters I get:
if (Mode == CPowerMeter::e_Software)
{
// Set PM's offset to 0.0.
Offset_dB(0.0, true);
}
else
{
assert(0); // Only software PM offsets supported right now.
}
Which is the transformed equivalent of what I started with and satisfies our coding standard. What I was requesting was that Refactor Pro be able to do all the above in one step. It would be nice if refactored code would be equivalent in both syntax and style.
Hi Mike,
Thank you for the response, and for the sample code you provided.
I've reproduced this problem locally, and it looks like an issue in the current product version. So, I've converted this suggestion to a bug report, and we'll do our best to fix it as soon as we can.
Thanks,
Vito
Hi Mike,
We've fixed this problem, and this fix will be included in the next product version.
However, please note that the current Refactor! version doesn't persist the source code style, i.e. the "additional delimiters" we're talking about will be removed after applying the refactoring. We do understand that this is a serious limitation, and are planning to address it in the future. Please track the following suggestion to be informed of our progress over this item:
ID: S19229, CodeGen - Add options to specify code generation rules
Thanks,
Vito