Artefact Relaxation

In order to allow users to relax or exclude artefacts from the project Artefact Tree, you need to reserve one measure that uses a special attribute used for relaxation and specify to which artefact types it applies.

Defining relaxation measure

The following is a basic example of how to allow users to relax folders and files in your model:

<!-- myModel/Analysis/Bundle.xml -->
<ArtefactType id="RELAXABLE" heirs="FOLDER;FILES" />
<Measure measureId="RELAX" targetArtefactTypes="RELAXABLE" defaultValue="0" usedForRelaxation="true" />

Only one measure in your model may use the usedForRelaxation attribute.

By adding these two lines in your model, you allow users whose role grant the View Drafts of Projects and Modify Artefacts privileges to use the relaxation mechanism. For more information about using artefact relaxation from the web UI, consult the Getting Started Guide.

Any type of artefacts can be relaxed, except source code artefacts below the file level (functions, classes, etc…​) for which relaxation will not be considered.

Impact on computations

When an artefact is relaxed, its metrics are ignored when computing metrics for other artefacts.

For example, this makes sense when relaxing a folder full of third-party code, because you may not want the total number of software lines of code to include third-party code. In other situations, it does not make sense to exclude all metrics from relaxed artefacts.

Like if you are analysing components of a system and aggregating memory usage information up to the application level, then third-party components for which you relax source code issues should still be part of the total memory usage for the system.

In the latter case, you can use the continueOnRelaxed attribute to indicate that some or all measures should be included in computations even if the artefact has been relaxed. This is explained in the two examples below.

Keep in mind that relaxation status is not known to any Data Providers except Squore Analyzer. Therefore, when manipulating and computing data in custom Data Providers, some artefacts metrics might still be considered even though these artefacts have been relaxed.

Example 1

In the following code continueOnRelaxed is set to true for the metric used to mark artefacts as relaxed (usedForRelaxation). As a result, all measures of the relaxed artefact are included in computations for other artefacts:

<ArtefactType id="RELAXABLE" heirs="FOLDER;FILES" />
<Measure measureId="RELAX" targetArtefactTypes="RELAXABLE" usedForRelaxation="true" continueOnRelaxed="true" defaultValue="0" />
Example 2

In the following code, continueOnRelaxed is set to true at computation-level. As a result, the measure MEMORY is included in computations even when the artefact is relaxed. No other measures are included in computations for relaxed artefacts, since continueOnRelaxed is omitted from the definition of RELAX:

<ArtefactType id="RELAXABLE" heirs="FOLDER;FILES" />
<Measure measureId="RELAX" targetArtefactTypes="RELAXABLE" usedForRelaxation="true" defaultValue="0" />
<Measure measureId="MEMORY" defaultValue="0">
	<Computation targetArtefactTypes="APPLICATION;FOLDER" result="SUM FILE.MEMORY FROM DESCENDANTS" continueOnRelaxed="true"/>
</Measure>

If you need to find out if an artefact is relaxed in your model, you can use the IS_RELAXED_ARTEFACT() function described in Conditional and level-related functions.