[offtopic] Coverity . . .
Frans Englich
frans.englich at telia.com
Thu Apr 20 01:05:32 BST 2006
On Wednesday 19 April 2006 23:10, Frans Englich wrote:
> On Wednesday 19 April 2006 22:45, Alexander Neundorf wrote:
[...]
> It would certainly be interesting. One could write the tests in XQuery or
> XSL-T
An example:
C++ code:
------------------------------------------
class KFoo
{
void SetMyProp(bool newValue);
};
------------------------------------------
gcc-xml output:
------------------------------------------
<GCC_XML>
<Namespace id="_1" name="::" members="_3 " mangled="_Z2::"/>
<Namespace id="_2" name="std" context="_1" members="" mangled="_Z3std"/>
<Class id="_3" name="KFoo" context="_1" mangled="4KFoo" location="f0:2" file="f0" line="2" members="_4 _5 _6 " bases=""/>
<Constructor id="_4" name="KFoo" artificial="1" throw="" context="_3" mangled="_ZN4KFooC1ERKS_ *INTERNAL* " location="f0:2" file="f0" line="2">
<Argument name="_ctor_arg" type="_7"/>
</Constructor>
<Constructor id="_5" name="KFoo" artificial="1" throw="" context="_3" mangled="_ZN4KFooC1Ev *INTERNAL* " location="f0:2" file="f0" line="2"/>
<Method id="_6" name="SetMyProp" returns="_8" access="private" context="_3" mangled="_ZN4KFoo9SetMyPropEb" location="f0:3" file="f0" line="3" extern="1">
<Argument name="newValue" type="_9"/>
</Method>
<ReferenceType id="_7" type="_3c"/>
<FundamentalType id="_8" name="void"/>
<FundamentalType id="_9" name="bool"/>
<CvQualifiedType id="_3c" type="_3" const="1"/>
<File id="f0" name="t.cpp"/>
</GCC_XML>
------------------------------------------
XQuery:
------------------------------------------
xquery version "1.0" encoding "UTF-8";
declare variable input := "outputs/gcc-xml-output.xml" as document();
(: Select every Method element that is a child of the Child element which in turn is child of GCC_XML, and which has an attribute by name 'name' and whose content starts with Set :)
(: We only want methods which has one argument. :)
for $i in $input/GCC_XML/Class/Method[starts-with(./@name, "Set") and count(./Argument) eq 1) return
<error>
<file name="{//File[@id eq $i/@file]}"
line="{$i/@line}"/>
<description>The function {$i/@name} of class {../@name}
is a setter and should therefore not start with 'Set', but 'set.'</description>
</error>
------------------------------------------
Produces:
------------------------------------------
<error>
<file name="t.cpp" line="3"/>
<description>The function SetMyProp of class KFoo is a setter and
should therefore not start with 'Set', but 'set.'</description>
</error>
------------------------------------------
And transform it to HTML, pipe it onto EBN, etc.
Right, this is not enough for eliminating false positives(and it's not tested). I'm merely demonstrating my point.
Cheers,
Frans
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20060420/8ceaecac/attachment.htm>
More information about the kde-core-devel
mailing list