This tutorial is dedicated to application developers, and requires some basic technical knowledge about:
We recommend two tools to test REST API.
The first one is cURL. This tool allow you to test all calls of this tutorial. If you are using the default basic authentication, you just have to set a username:password as cast:cast, to perform a GET request:
C:> curl –u cast:cast http://demo-eu.castsoftware.com/Health/rest/AAD
The second one is the Simple REST Client provided with the REST API. This Web Page provides a simple view of JSON response, that allows you to navigate across REST resources.
You can access this page from a web browser with the following URL:
http://demo-eu.castsoftware.com/Health/static/default.html
The steps to use this client are:
Warning: If you are using another REST client, you must ensure, that this Web Client sends the following HTTP headers:
Accept: application/json
Authorization: Basic Y2FzdDpjYXN0
Warning: Ensure that your web client is able to take into account caching on server side. For some URLs, if you attempt to get the same resource twice, you may receive a response with status HTTP 304 Not Modified with an empty body.
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.
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.
Some URLs contain query string, you should encode this part of the URL, especially for special characters in names ('C++' for example).
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.
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
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
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 |
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:
| |
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. |
A configuration is defined for each snapshot. To get all available configurations:
GET http://demo-eu.castsoftware.com/Health/rest/AAD/configurations
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
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
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
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.
Analysis Results can be accessed with a combination of selectors:
metrics selectors
metrics can be
There is a single structure for assessment results. Assessment results are reported as a collection. Each item of this collection identifies an application snapshot:
|
|
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
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
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
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
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
Some sizing-measures are dedicated to the total number of critical violations according to some criteria:
Sizing-measure | URL |
---|---|
Critical violations per file |
|
Critical violations per KLOC |
|
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
Order the result by totalChecks
Add the 'select' selector, to get details on a result when quality-indicator results are fetched:
'select' option | Additional Result Properties |
---|---|
evolutionSummary |
|
violationRatio |
|
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
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
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