SQL Queries - CAST Central Base - Queries on Metrics - How to get the cyclomatic complexity by type of objects for a specific snapshot

Purpose of Query

 The query provided in this page gives the cyclomatic complexity computed for every type of object present in the application for a specific snapshot.

Applicable CAST Version
Release
Yes/No
8.3.x (tick)
8.2.x (tick)
Applicable RDBMS
RDBMS
Yes/No
Oracle Server(tick) 
Microsoft SQL Server (tick)
CSS (tick)


Query for CSS

Following query needs to be run on the central database CB 

SELECT   dmr.snapshot_id     ,
         dot.object_type_id  ,
         dot.object_type_name,
         COUNT(*)                 AS TotalObj,
         SUM(dmr.metric_num_value)AS TotalCC
FROM     dss_metric_results dmr
         JOIN dss_objects dos
         ON       dos.object_id = dmr.object_id
         JOIN dss_object_types dot
         ON       dot.object_type_id = dos.object_type_id
         AND      dot.object_group   =0
WHERE    metric_id IN (65504,65502,65505,65503)
AND      dmr.snapshot_id    =snapshot_id --please replace with the Id of the snapshot for which you want to get the cyclomatic complexity
AND      metric_value_index =1
GROUP BY dmr.snapshot_id   ,
         dot.object_type_id,
         dot.object_type_name
ORDER BY dot.object_type_id  ,
         dot.object_type_name,
         dmr.snapshot_id
Query result example
 

Here is an example of returned rows (for snapshot_id=12)

12;101;"Java Constructor";2182;3060

Query result interpretation
 In snapshot 12, the total cyclomatic complexity associated to Java Constructor type (type 101) is 3060 for 2182 objects
Query for Oracle
Same as for CSS
Query result example
 Same as for CSS
Query result interpretation
 Same as for CSS
Query for SQL server
Same as for CSS
Query result example
 Same as for CSS
Query result interpretation
 Same as for CSS
Notes/comments



Related Pages