Contents

Prerequisite

This tutorial is dedicated to application developers, and requires some basic technical knowledge about:


How to start

We recommend two tools to test REST API.


Best practices to construct REST URLs

  1. We recommend to construct REST URLS with URI returned by REST resources. We discourage the construction of REST URLs with hard-coded identifiers.
    Indeed, after a database upgrade, some identifiers may be changed, and the hard coded URLs may be no longer valid.

  2. An analyzed applications can be identified with a URI or with a name. We recommend to use URI, as the name of an application may be not unique.

  3. Some URLs contain query string, you should encode this part of the URL, especially for special characters in names ('C++' for example).


Portfolio of Applications

Notion of domain

Domain
A domain is a logical name of a database containing assessment results.

Most of the time, you will get a single domain. To get available domain names, use the following REST URL:

GET http://demo-eu.castsoftware.com/Health/rest

From the Domain you will get all URIs to retrieve analyzed applications.

Warning: Do not confuse the REST domain with the web server domain. The Web Server domain identifies the deployed REST services, the REST domain identifies a database.

Retrieve all analyzed applications

To retrieve all applications that have been analyzed, fetch a domain as a resource (here AAD):

GET http://demo-eu.castsoftware.com/Health/rest/AAD 

List all snapshots of an application

Snapshot
A snapshot stores assessment results for a given date, and the associated configuration of metrics. It is a measurement point of an application.

To retrieve the collection of all snapshots of an application, select a URI of an application, and then the URIs of all snapshots, you will build then the following URL:

GET http://demo-eu.castsoftware.com/Health/rest/AAD/applications/55/snapshots 

Configuration

Configuration
A configuration defines all metrics, quality rule patterns, and calculation rules to compute high level indicators.

Quality Indicator
A metric indicating a quality score, that is a grade between 1.00 and 4.00, with 4.00 as the best possible score.

A quality indicator identifies a risk level:

Grade Value Risk Level
From 1.0 to 2.0 Very High Risk
From 2.0 to 3.0 High Risk
From 3.0 to 4.0 Moderate Risk
4.0 Low Risk

Sizing Measure
A metric indicating a quantitative property about an application source code: number of lines, technical debt, etc.

Background fact
Additional data imported from an external system as a metric.

Metrics are divided into 3 metrics types, each of them divided into groups:

Metrics Types Metrics Groups Metrics
quality-indicators business-criteria TQI, Robustness, Efficiency, Security, Changeability, Transferability, SEI Maintainability.

The grade calculation is based on the average of a list of Technical Criteria linked to a list of specific Quality Rules
technical-criteria Level 2 of CAST Assessment Model.

The grade calculation is based on the average of specific Quality Rules
quality-rules About 900 through CAST Assessment Model.

The grade calculation is based on a ratio between failed checks and total checks of objects
quality-distributions A grade computed from a distribution of objects into 4 categories:

  • Very Large/Very High/li>
  • Large/High/li>
  • Medium
  • Small/Low
quality-measures Sizing values that outline code quality: Percentage of commented-out code lines, Percentage of copy pasted code, SEI Maintainability index, etc.
sizing-measures technical-size-measures Lines of code, Critical violations, Technical Debt, Files, Artifacts, Lines of Comment
run-time-statistics CPU time, Database time
technical-debt-statistics Technical Debt, Technical Debt Density
critical-violations-statistics Violations of Quality Rules tagged as critical for a business criterion
functional-weight-measures OMG Automated Function Points, Enhancement Function Point (Added, Modified, Removed), Number of Decision Point (cyclomatic complexity), Backfired Function Point
background-facts n/a Additional data imported from an external system as a metric.

How to get all configurations

A configuration is defined for each snapshot. To get all available configurations:

GET http://demo-eu.castsoftware.com/Health/rest/AAD/configurations 

How to get all quality-indicators

When a configuration has been selected, a collection of all quality indicators is fetched as follow:

GET http://demo-eu.castsoftware.com/Health/rest/AAD/configuration/snapshots/1/quality-indicators

How to get all sizing measures

When a configuration has been selected, a collection of all sizing measures is fetched as follow:

GET http://demo-eu.castsoftware.com/Health/rest/AAD/configuration/snapshots/1/sizing-measures

How to get all background facts

When a configuration has been selected, a collection of all background facts is fetched as follow:

GET http://demo-eu.castsoftware.com/Health/rest/AAD/configuration/snapshots/1/background-facts

Analysis Results

Analysis Result
An assessment result is a computed value of a metric qualifying a code quality or measuring a size.

Each assessment result refers either to the whole source code of an application, or to a subset of source code.

There are two types of source code subset:

Each assessment result belongs also to a snapshot.

Selectors

Analysis Results can be accessed with a combination of selectors:

Structure of an Analysis Result

There is a single structure for assessment results. Assessment results are reported as a collection. Each item of this collection identifies an application snapshot:


	{
		"number": 3,
		"date": { "time": 1384729200000	},
		"application": { "href": "AAD/applications/106", "name": "Arizona" },
		"applicationSnapshot": { "href": "AAD/applications/106/snapshots/11", "name": "Arizona"	},
		"applicationResults": [
				{
				"type": "business-criteria",
				"reference": {
					"href": "AAD/quality-indicators/60017/snapshots/11",
					"name": "Total Quality Index",
					"shortName": "TQI",
					"key": "60017",
				},
				"result": {
					"grade": 3.1746451790243237,
					...
				},
				"technologyResults": [],
				"moduleResults": []
			}
		]
	}

Start of item
Ordinal number of application snapshot
Snapshot date
Reference to the associated application
Reference to the associated application snapshot
Start of assessment results
An assessment result
Type of assessment result
Reference to the associated metric





Assessment result data
Grade value
Additional value depending on 'select' selector

Split up of assessment result by technology
Split up of assessment result by module



How to fetch the total quality index

Total Quality Index of application named 'MyApp' for the last snapshot:

GET http://demo-eu.castsoftware.com/Health/rest/AAD/results?quality-indicators=60017&snapshots=-1&applications=MyApp`

Evolution of the Total Quality Index between the last snapshot and the previous one:

GET http://demo-eu.castsoftware.com/Health/rest/AAD/results?quality-indicators=60017&snapshots=-2&applications=MyApp 

Total Quality Index for all applications, considering the last snapshot of each one:

GET http://demo-eu.castsoftware.com/Health/rest/AAD/results?quality-indicators=60017&snapshots=-1&applications=$all 

How to fetch some sizing measures

Number of lines of code of 'MyApp' application for the last snapshot

GET http://demo-eu.castsoftware.com/Health/rest/AAD/results?sizing-measures=10151&snapshots=-1&applications=MyApp 

Technical Debt of 'MyApp' application for the last snapshot

GET http://demo-eu.castsoftware.com/Health/rest/AAD/results?sizing-measures=68001&snapshots=-1&applications=MyApp 

How to fetch a pair of results

You can get both a quality indicator and a sizing measure, for example Total Quality Index and Line of Codes:

GET http://demo-eu.castsoftware.com/Health/rest/AAD/results?quality-indicators=60017&sizing-measures=10151&snapshots=-1&applications=MyApp  

You can get a list of quality indicators also, for example, two health factors: Efficiency, and Security:

GET http://demo-eu.castsoftware.com/Health/rest/AAD/results?quality-indicators=(60014,60016)&snapshots=-1&applications=MyApp  

How to fetch evolution of a metric

Select the two last snapshots in order to make the difference between between the 2 results. Note that the results are ordered from the most recent one to the less recent one.

GET http://demo-eu.castsoftware.com/Health/rest/AAD/results?quality-indicators=60017&snapshots=-2&applications=MyApp   

Violations and critical violations

Violation
A violation identifies a component breaking a quality rule.
Critical Violation
A critical violation is a violation of a quality rule, this quality rule is identified as critical regarding a technical criterion or a business criterion.
Object
An object is a source code item such as a class, a method, etc. The effective definition depends on the programming language and the technology of the analyzed application.
Defective Object
A defective object is a source code item in violation with at least one quality rule.
Complex Object
A complex object is a source code item with a High Cost Complexity (aka CAST Complexity).

How to get number of complex objects with violations

The total number of complex objects is the sum of categories High Cost Complexity Artifacts, Very High Cost Complexity Artifacts for Quality Distribution 67001.

GET http://demo-eu.castsoftware.com/Health/rest/AAD/results?quality-indicators=67001&select=categories&snapshots==-1&applications=MyApp

The total number of complex objects with violations of categories High Cost Complexity Violations, Very High Cost Complexity Violations for Quality Distribution 67020.

GET http://demo-eu.castsoftware.com/Health/rest/AAD/results?quality-indicators=67020&select=categories&snapshots=-1&applications=MyApp

How to get statistics on critical violations

Some sizing-measures are dedicated to the total number of critical violations according to some criteria:

Sizing-measure URL
Critical violations per file
GET http://demo-eu.castsoftware.com/Health/rest/AAD/results?quality-indicators=67012&snapshots=-1&applications=MyApp
Critical violations per KLOC
GET http://demo-eu.castsoftware.com/Health/rest/AAD/results?quality-indicators=67015&snapshots=-1&applications=MyApp

How to get top ten critical quality rules in violation

  1. Fetch all critical contributors to Total Quality Index with 'cc:' prefix

    GET http://demo-eu.castsoftware.com/Health/rest/AAD/results?quality-indicators=cc:67017&snapshots=-1&applications=MyApp&select=violationRatio
  2. Order the result by totalChecks

  3. Get the first 10 results

How to get violations statistics by quality indicators

Add the 'select' selector, to get details on a result when quality-indicator results are fetched:

'select' optionAdditional Result Properties
evolutionSummary
  • removedCriticalViolations: critical violations removed since the previous snapshot
  • addedCriticalViolationsNewCode: critical violations added since the previous snapshot in new code only
  • addedCriticalViolationsModifiedNewCode: critical violations added since the previous snapshot
  • totalCriticalViolations: total number of critical violations in this snapshot
violationRatio
  • totalChecks: total number of checked items
  • failedChecks: total number of failed items
  • ratio: result of successfulChecks / totalChecks
  • successfulChecks: result of totalChecks - failedChecks

How to get critical quality rules grades impacting a business criterion

Add the 'cc:' prefix in front of the business criterion key:

GET http://demo-eu.castsoftware.com/Health/rest/AAD/results?quality-indicators=cc:60017&snapshots=-1&applications=MyApp

How to get quality rules grades impacting a technical criterion

Add the 'c:' prefix in front of the technical criterion key:

GET http://demo-eu.castsoftware.com/Health/rest/AAD/results?quality-indicators=c:61023&snapshots=-1&applications=MyApp

How to get technical criteria improvement opportunities

Add the 'c:' prefix in front of the Total Quality Index to get all the technical criteria:

GET http://demo-eu.castsoftware.com/Health/rest/AAD/results?quality-indicators=c:60017&select=violationRatio&snapshots=-1&applications=MyApp