Description

This page will provide the solution for a known issue with the calculation and display of the complexity on the left hand panel of dashboard. They are displayed as 0 on the dashboard.

The screenshots of the issue is given below, which will help in clarifying the issue:

Observed in CAST AIP
Release
Yes/No
8.3.x(tick)
Observed on RDBMS
RDBMS
Yes/No

CSS

(tick)
Step by Step Scenario

Below is the step-by-step scenario leading to the problem:

  1. Analyze an application and take a snapshot.
  2. Open the dashboard.
  3. Check if the Total CC on the left hand panel is displayed as 0
Impact of the Problem

The impact of the problem on the dashboard is: Dashboard does not display the expected results for the complexity even when the objects are analyzed.

Action Plan

To troubleshoot this issue, you need the following Relevant input

Perform the below actions:

  1. If your source code is .Net and if you are using CAST AIP < 7.3.9 then please refer to the section Technology Specific Issues and apply the given Solution . If this solution does not solve your issue or if this is not your case then move to next step.
  2. Take any artifact and check if any of the complexity metrics have been computed in KB
  3. If the metric is computed in KB, then Check if the complexity metric is computed in Central DataBase. If metric is not computed in CB then contact CAST Technical Support with Relevant input 
    For CAST Technical Support only please refer to the page - Important guidelines while reproducing a customer issue - CAST Internal 
  4. Else if the metric is not computed in KB, then Check the Metric Assistant log to see if the metric is computed . If the metric is computed from the logs then contact CAST Technical Support with Relevant input 
  5. If there is no row indicating metric has been computed or if there is any error or warning while computing metrics then the issue is with the Metric Assistant , please refer to the page - CMS Snapshot analysis - Run Metrics Calculation


Relevant input

  1. CAST Support Tool (CST) - alias Sherlock with options Export CAST Databases , Export Source code , Export Logs , configuration Files

  2. Complete screenshot of the dashboard showing the problem.

Take any artifact and check if any of the complexity metrics have been computed in KB

  1. Take an example artifact from dssapp_artifacts table which has a non-zero LOC

    select object_id , code_lines from <LOCAL_DATABASE>.dssapp_artifacts where code_lines > 0 limit 5

    Example -
    Object_id;code_lines 

    14769475;5
    14768953;74
    14771246;77
    8739801;3
    14766834;8

    We can see that the above 5 objects have LOC > 0 and we can pick any object for investigation.

  2. Check in dss_metric_results table on KB if any of the metrics - (65504,65502,65505,65503) have been computed

    select metric_id , object_id,metric_num_value 
    from <LOCAL_DATABASE>.dss_metric_results 
    where metric_id in (65504,65502,65505,65503) 
    and metric_value_index = 1 
    and object_id = <OBJECT_ID>

    Example -
    metric_id;object_id;metric_num_value
    65502;14769475;1

    If the query returns zero rows it means that the metric Cyclomatic complexity has not been computed in the KB. In the above example the cyclomatic complexity of the object 14769475 is 1, CC is computed.

Check if the complexity metric is computed in Central DataBase

  1. Check in dss_metric_results table on CB if any of the metrics - (65504,65502,65505,65503) have been computed

    select metric_id , object_id,metric_num_value 
    from <CENTRAL_DATABASE>.dss_metric_results 
    where metric_id in (65504,65502,65505,65503) 
    and metric_value_index = 1 
    and object_id = (Select object_id from <CENTRAL_DATABASE>.dss_translation_table where site_object_id = <OBJECT_ID>)

    Example -
    metric_id;object_id;metric_num_value
    65502;334;1

    If the query returns zero rows it means that the metric Cyclomatic complexity has not been computed in the CB. In the above example the cyclomatic complexity of the object 334 is 1, CC is computed.

Check the Metric Assistant log to see if the metric is computed

  1. Locate the Metric Assistant log by refering to the page CAST Management Studio - Information - How to find logs and search for Run Metrics Calculation
  2. Get the name of the file containing the object by using the page - SQL Queries - CAST Knowledge Base - Queries on source code - How to get the source code for a given object id
  3. Search for a line indicating that the metric is computed for that file. For instance if the name of the file is - Architecture.ksh the the log should contain a line like below -
    2017-04-18 10:22:23.595  Information Computing metrics on D:\Deploy\c4a9cc545480499cbb2ea4aef590c7ca/Scr13481\..\3732861757_SHELL\Architecture.ksh
Solution

Technology Specific Issues

.Net

The reason why this problem happened is because there was a Runtime error during the metric computation. Mostly, this error comes on specific files and in this case it came from file \pkelibre\ihm\InTheHand.Net.Personal\Net\Sockets\BluetoothClient.cs.

The cause why this run time error occurred is because inside this file there a comment like the following:

/*#else
                BTHNS_INQUIRYBLOB bib = new BTHNS_INQUIRYBLOB(Convert.ToInt16(inquiryLength.TotalSeconds / 1.28), (short)maxDevices);
                GCHandle hBib = GCHandle.Alloc(bib.ToByteArray(),GCHandleType.Pinned);
                IntPtr pBib = new IntPtr(hBib.AddrOfPinnedObject().ToInt32() + 4);
#endif*/

and this comment raise a runtime error for commented code line metrics because there a #else without #if.

Solution

The Solution in this case is to run the analysis by removing this file from the source file folder.

The culprit file can also be renamed to something like: BluetoothClient.cs_deleted and as the extension will be changed, the analyzer will not analyze this culprit file.

Below is a screenshot of the Complexity computed by running an analysis after applying the above mentioned:



This problem has been permanently fixed in CAST AIP 7.3.9.

Impact of the solution on the dashboard is: The Total CC will display the computed value and will not display 0.

Notes/comments
Ticket # 4202
Related Pages