In the last post we learned that Panopticode 0.2 will allow us to create arbitrary reports using a SPARQL SELECT query. Another feature in Panopticode 0.2 is to use a SPARQL ASK query to break the build.
An ASK query looks very similar to a SELECT but without any elements to return. If the query matches any data it returns true, otherwise it returns false.
Rewriting last post’s SELECT query as an ASK query would look like:
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX panopticode: <http://www.panopticode.org/ontologies/panopticode#>
PREFIX java: <http://www.panopticode.org/ontologies/technology/java#>
PREFIX emma: <http://www.panopticode.org/ontologies/supplement/emma/1#>
PREFIX javancss: <http://www.panopticode.org/ontologies/supplement/javancss/1#>
ASK WHERE
{
?package rdf:type java:Package .
?package panopticode:name ?packageName .
?package java:hasFile ?file .
?file panopticode:filePath ?filePath .
?file java:hasType ?class .
?class panopticode:name ?className .
?class java:hasExecutableMember ?method .
?method java:methodSignature ?methodSignature .
?method emma:hasLineCoverage ?lineCoverage .
?method javancss:cyclomaticComplexity ?ccn .
?lineCoverage emma:coveredPercent ?lineCoveragePercent .
FILTER (?ccn > 1) .
FILTER (?lineCoveragePercent <= 80.0)
}
Panopticode 0.2 will come with an Ant task that automatically breaks the build when an ASK query returns true.