Hi all,
I'm writing a C# application that identifies coding standards issues in a bespoke language (Siebel eScript, if you're interested - it's based on ECMAScript).
Two of the items I want to address are:
1. Attempting to use 'return' within a finally block:
...
catch(e)
{
logError(e);
}
finally
{
if (e.ToString() != "")
{
// Return in finally - this is bad
return (false);
}
else
{
// Return in finally - this is bad
return (true);
}
}
return(true)
}
2. Initialising an object type witout destroying it by setting in to null:
...
var oObject1 = TheApplication().NewPropertySet();
var oObject2 = TheApplication().GetBusObject("Account);
var oObject3 = oObject2.GetBusComp("Contact");
...
// Failed to set oObject1 to null
oObject2 = null;
oObject3 = null;
I currently use some horrible string manipulation to address item 1 (using indexOf and subString) and I haven't even begun to fathom how to achieve item 2.
I was wondering if there are RegEx expressions that I could use to identify code scripts that meet the above contraints? The input would be an entire function / script and I really only need a 'yes' or 'no' for each item, as to whether the script passed in violates the rule or not.
Any thoughts greatly appreciated.
Regards,
mroshaw