Models

Models define how Squore computes metrics (analysis model), how action items are created (decision model), and how data is displayed (dashboards and reports).

All models are located in the <INSTALLDIR>/Configuration/models directory.

The Shared Model

Some components are common to many models. Rather than creating redundancy, and redefining the same metrics or indicators every time, Squore uses the Shared Model to store definitions that may be used by more than one model.

The Shared Model is located in the same directory as other models: <INSTALLDIR>/Configuration/models. Its structure is similar to other models, but it does not appear in the user interface. To understand some of the common measures and rules used across Squore you can take a look at the common definitions available in Shared/Analysis/Code, especially:

  • ArtefactRating

  • BaseMeasures (lists common base measures gathered by the Data Providers)

  • CallRelation

  • ControlFlowAnalysis

  • LineCounting

  • ObjectOrientation

  • RuleChecking

  • StabilityIndex

  • TechnicalDebt

Creating a New Model

If there are several customisations in your model, then you should create a new model to isolate them. This will be easier for maintenance and upcoming upgrades of Squore Server. The following procedure describes how to create a new model:

  1. Create a new directory MyModel in the <INSTALLDIR>/Configuration/models directory.

  2. In the MyModel folder, create the following sub-folders: Analysis, Dashboards, Decision, Description, Exports, Reports and Wizards.

  3. Logout and login to see the result. Browse the Model Explorer button in Squore and select the newly created model.

Customising Squore

Bundle File

A model is a collection of several Bundle.xml files where your entire model is described. A model folder normally contains the following bundles:

  • myModel/Analysis/Bundle.xml, where artefact types, metrics, indicators and rules are defined

  • myModel/Dashboard/Bundle.xml, where the charts displayed in the web interface are defined

  • myModel/Decision/Bundle.xml, where you define the action items for your model

  • myModel/Description/Bundle.xml, where you translate all the elements of your model into several languages

  • myModel/Exports/Bundle.xml, where you define the type of information that users can export from the web UI

  • myModel/Highlights/Bundle.xml, where the different types of highlight categories are defined

  • myModel/Properties/Bundle.xml, where optional properties about your model are defined

  • myModel/Reports/Bundle.xml, where you define the type of reports that can be created from the web UI

  • myModel/Wizards/Bundle.xml, where you define the parameters to be used when creatign a project with your model

More information about each type of bundle is available in this manual. Note that a Bundle.xml file normally includes external files located elsewhere in the standard Squore configuration. This allows reusing modules between models.

The following is an (incomplete) example of a Bundle.xml file that includes other files from the Squore configuration. Note that the xmlns:xi declaration in the Bundle element is mandatory if you want to include external files.

<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<Bundle xmlns:xi="http://www.w3.org/2001/XInclude" >
    <!-- Aliases -->
    <ArtefactType id="CODE" heirs="PACKAGES;FILES;CLASSES;MODULES" />
    <ArtefactType id="PACKAGES" heirs="APPLICATION;SOURCE_CODE;FOLDER" />
    <ArtefactType id="FILES" heirs="FILE" />
	<ArtefactType id="CLASSES" heirs="CLASS" />

	<xi:include href="../../Shared/Analysis/SQuORE_BasicScales.xml" />	   
	
		<!-- SQuORE Base Measures -->
	<xi:include 
	  href="../../Shared/Analysis/product_quality/code/line_counting/line_counting.xml" />
	<xi:include 
	  href="../../Shared/Analysis/Code/ObjectOrientation/squore_java_oo_basemeasures.xml" />
	<xi:include 
	  href="../../Shared/Analysis/Code/ObjectOrientation/SQuORE_Inheritance.xml" />

		<!-- Rule Checking -->
	<xi:include 
	  href="../../Shared/Analysis/Code/RuleSet/SQuORE_Java_RuleSet.xml" />

		<!-- SQALE Analysis Model -->
	<xi:include 
	  href="../../Shared/Analysis/Code/SQALE/SQALE_Characteristics.xml" />
	<xi:include href="SQALE_Requirement.xml" />

	<RootIndicator indicatorId="SQALE_INDEX_DENSITY" artefactTypes="APPLICATION;FOLDER;SOURCE_CODE" />
	<RootIndicator indicatorId="SQALE_INDEX" artefactTypes="FUNCTION;CLASS;FILE" />
	<Measure measureId="COST" targetArtefactTypes="APPLICATION" defaultValue="0" />
</Bundle>

Warning

The bundle file is an xml file, which means that you must respect the XML syntax, otherwise Squore will not be able to read it. This means for example that the following characters are forbidden, and must be replaced by their corresponding entity reference:

  • & needs to be replaced by &amp;

  • < needs to be replaced by &lt;

  • > is preferably replaced by &gt;, but this is not mandatory

  • " needs to be replaced by &quot; (only when used inside an attribute value)

  • ' needs to be replaced by &apos; (only when used inside an attribute value)

To learn more about entities, visit en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references

Descriptions

For the easy customisation of labels displayed in the Squore interface, all strings have been externalised to localisable properties files . For each XML file containing definitions (e.g. for scales, indicators, measures, etc.) there is a file with the same name and a .properties extension for each target language (_en and _fr by default). As an example, the English properties files for the Checkstyle_RuleSet.xml file is located in the same directory and called Checkstyle_RuleSet_en.properties.

Squore will select the appropriate language to use according to the language options defined in the description bundle:

<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<Bundle available="fr,en" default="en">
	<Properties src="Checkstyle_RuleSet" />
</Bundle>

In the example above, it is assumed that two files exist with the names Checkstyle_RuleSet_en.properties and Checkstyle_RuleSet_fr.properties, since you declared both languages in the available attribute. Users are free to switch between the English and French languages using the flag icons in Squore's web interface. By default, Squore will display the descriptions from Checkstyle_RuleSet_en.properties, since you set the default language to "en" using the default attribute.

Properties files are simple text files containing key-value pairs of internal unique identifier (often referred to as the ID) and language-dependent mnemonics, names, descriptions, help URL and justifications. The convention used for their syntax is the following:

  • <TYPE>.<MY_STRING_ID>.MNEMO=MYSTRING.<ARTEFACT-TYPE>

  • <TYPE>.<MY_STRING_ID>.NAME.<ARTEFACT-TYPE>=My String

  • <TYPE>.<MY_STRING_ID>.TREE_NAME.<ARTEFACT-TYPE>=My String (for charts and tables only, the name shown in the Dashboard Editor's tree) (since 13-B)

  • <TYPE>.<MY_STRING_ID>.ICON=path/to/icon.ico (for trend and group icons) (since 14-A)

  • TYPE.<MY_STRING_ID>.NODATA=My String (for charts only: the string displayed in the dashboard if there is no data to draw a chart) (since 14-A)

  • <TYPE>.<MY_STRING_ID>.DESCR.<ARTEFACT-TYPE>=This is a long description about my string.

  • <TYPE>.<MY_STRING_ID>.JUSTIF.<ARTEFACT-TYPE>=<a category that MYSTRING belongs to>

  • <TYPE>.<MY_STRING_ID>.URL.<ARTEFACT-TYPE>=https://intranet/wiki/Indicator

<TYPE> and <ARTEFACT-TYPE> are optional, but they can help you specify exceptions when viewing a measure for a certain type of artefact. Squore will resolve properties from the more specific to the more abstract, as shown below:

  1. T.ID.NAME.FILE
  2. T.ID.NAME
  3. ID.NAME.FILE
  4. ID.NAME

The following is an example of the declaration of SLOC:

M.SLOC.MNEMO=SLOC
  M.SLOC.NAME=Source Lines Of Code
  M.SLOC.DESCR=Number of lines of source code in the /application.
  M.SLOC.JUSTIF=MAINTAINABILITY

Note that in the example above, / is used to indicate a new line in the description, and SLOC is of type measure, as indicated by the prefix M.

The other available prefixes are:

  • I for INDICATOR

  • M for MEASURE

  • FA for FAMILY

  • LOP for LEVELOFPERFORMANCE

  • FI for FINDING

  • T for TYPE

  • RO for ROLE

  • PRO for PROFILE

  • PERM for PERMISSION

  • SC for SCALES

  • ST for STATUS

  • TST for TEST

  • C for CHART

  • TA for TABLE

  • RE for REPORT

  • EX for EXPORT

  • MO for MODEL

  • WI for WIZARD

  • EVO for trend icons (since 13-B)

  • HI for HIGHLIGHT (since 13-C)

  • G for GROUP (since 14-A)

Tip

Properties files are also used to customise tooltips appearing on the dashboard, as described in the section called “Using Tooltips”

Defining Types

Types are defined in the <INSTALLDIR>/Configuration/models/Shared/Analysis/Code/Types/types_en.properties properties file. Other languages are defined in the same directory with a different ending (e.g. types_fr.properties for French). Types are then used in all declarations that provide artefact-level information, like e.g. in measures:

<Measure measureId="DIT"  
    targetArtefactTypes="CLASS" 
    defaultValue="1" />

Defining Rights

Rights are described and translated in the <INSTALLDIR>/Configuration/models/Shared/Description/rights_en.properties properties file. Create your own language file by changing the language ending of this file, e.g. rights_ru.properties for Russian.

Defining Roles

Roles are described and translated in the <INSTALLDIR>/Configuration/models/Shared/Description/roles_en.properties file. There is one file per language, create your own language file by changing the language ending of this file, e.g. roles_ru.properties for Russian.

Defining Statuses

Statuses are described and translated in the <INSTALLDIR>/Configuration/models/Shared/Description/status_en.properties file. There is one file per language, create your own language file by changing the language ending of this file, e.g. status_ru.properties for Russian.