Simple Calculation Syntax

In order to compute results for the current artefact, the basic operators +, -, * and / allow to respectively add, subtract, multiply and divide the values of two operands. Parentheses are allowed at any nesting level.

The following examples describe valid uses of the operators in Squore models. Note that spaces were added between operands to simplify reading the formulae, but they are not required.

Take the value of LC, subtract SLOC and add 10:

<Measure measureId="COMR" defaultValue="0">
<Computation targetArtefactTypes="FILE;FUNCTION;CLASS"
result="LC - SLOC + 10" />
</Measure>

Using both base and derived measures (B.SLOC and SLOC respectively) in the same calculation:

<Measure measureId="COMR" defaultValue="0">
<Computation targetArtefactTypes="FILE;FUNCTION;CLASS"
result="LC - B.SLOC + (-04 - SLOC)" />

Multiplying operands:

<Measure measureId="COMR" defaultValue="0">
<Computation targetArtefactTypes="FILE;FUNCTION;CLASS"
result="LC * SLOC * 6.0" />
</Measure>

Using the opposite value of an operand:

<Measure measureId="COMR" defaultValue="0">
<Computation targetArtefactTypes="FILE;FUNCTION;CLASS"
result="0.1 * -LC + 2 * -SLOC * 3" />
</Measure>

Dividing values:

<Measure measureId="COMR" defaultValue="0">
<Computation targetArtefactTypes="FILE;FUNCTION;CLASS"
result="LC + 2 / 2" />
</Measure>

Using the ranking of a measure instead of its value:

<Measure measureId="COMR" defaultValue="0">
<Computation targetArtefactTypes="FILE;FUNCTION;CLASS"
result="I.LC + I.SLOC / 3.5" />
</Measure>

Using the ranking of the root indicator for the artefact:

<Measure measureId="COMR" defaultValue="0">
<Computation targetArtefactTypes="FILE;FUNCTION;CLASS"
result="RANK + LC" />
</Measure>

	or

<Measure measureId="COMR" defaultValue="0">
<Computation targetArtefactTypes="FILE;FUNCTION;CLASS"
result="LEVEL + LC" />
</Measure>

Using the number of times the rule R_COMPOUNDIF was violated for the artefact:

<Measure measureId="COMR" defaultValue="0">
<Computation targetArtefactTypes="FILE;FUNCTION;CLASS"
result="R.R_COMPOUNDIF * 2" />
</Measure>

Note: If an erroneous formula is used, the measure will use the default value instead of the result of the computation:

<Measure measureId="COMR" defaultValue="0">
<Computation targetArtefactTypes="FILE;FUNCTION;CLASS"
result="LC / 0" />
</Measure>