SQL Queries - CAST Central Base - Queries on Metrics - How to get the source code position for objects with violations

Purpose of Query

This page provides a query which lists the source code position (if available) for objects with violations.

Applicable CAST Version

ReleaseYes/No
8.3.x
8.2.x

Applicable RDBMS

RDBMSYes/Notables
Oracle Server
Microsoft SQL Server
CSS2

Query for CSS

Substitute ‘XXX’ in the query below for your snapshot_id .  To obtain the snapshot_id, please see this page:  SQL Queries - CAST Central Base - Queries on snapshots - How to get the ID and name of a snapshot for a given application

Please Note:

  • csv tables must be populated for this query to properly work
  • Only violations will be shown that provide a source code position.  No rules that are not violated will be shown as well as violations that do not provide a source code position.

SELECT t.b_criterion_name AS BUSINESS_CRITERIA ,
t.t_criterion_name AS TECHNICAL_CRITERIA,
t.metric_name AS QUALITY_RULE ,
d.object_name AS OBJECT_NAME ,
p.start_line AS START_LINE ,
p.start_column AS START_COLUMN ,
p.end_line AS LINEEND ,
p.end_column AS COLENDFROM dss_source_positions p ,
csv_diagdetails d ,
csv_quality_tree tWHERE p.object_id = d.object_id
AND d.diag_id =t.metric_id
AND d.snapshot_id=XXX
ORDER BY t.b_criterion_name,
t.t_criterion_name,
t.metric_id ,
d.object_name ,
p.start_line ,
p.start_column;

Query result example

‘Changeability’,‘Architecture - Object-level Dependencies’,‘Avoid Artifacts with High Fan-Out’,’[C:\CASTMS\test834\Deploy\web\web\webapp\src\main\webapp\response.jsp]’,1,1,33,2
‘Changeability’,‘Architecture - Reuse’,‘Use of style sheets’,’[C:\CASTMS\test834\Deploy\web\web\webapp\src\main\webapp\WEB-INF\errors\generalError.jsp]’,1,1,20,2

Query result interpretation

The query lists the associated business and technical criterion associated with the violation, the violated metric, the name of the violated object, and information on the location in the code where the violation was found in the source code (such as starting line, starting column, ending line and ending column)

Query for Oracle

Enter the SQL query

Query result example

Query result interpretation

Query for SQL server

Enter the SQL query

Query result example

Query result interpretation

Notes/comments

Related Pages