Modifying The Report Template

It is possible to modify the look and feel of the default report. The report functionality uses a JasperReports template, an XML file with a .jrxml extension that can be edited in Jaspersoft Studio or in a text editor. The main template file (<SQUORE_HOME>/configuration/models/Shared/Reports/templates/template.jrxml) includes most of the other files in the templates folder as subreports and allows the data sent from Squore to be turned into the final report document.

Tip

For any help with JasperReports, consult the forums at https://community.jaspersoft.com/.

The template is split into the following sections:

Squore provides values for the following variables in the template automatically:

For each chart from the dashboard that you include in a report, the following parameters are also available:

Tip

Up to 16 charts (and their comment threads) can be included without modifying the default template.

Subreports are activated based on the presence of an XML element in the data sent by Squore. The following lines checks for the presence of a highlights category in the exported data with the following dataSourceExpression to activate the highlights.jrxml subreport:

<detail>
...
	<subreport>
		...
		<dataSourceExpression><![CDATA[((net.sf.jasperreports.engine.data.JRXmlDataSource)$P{REPORT_DATA_SOURCE}).subDataSource("//Highlights")]]></dataSourceExpression>
		<subreportExpression><![CDATA["/../../../Shared/Reports/templates/highlights.jasper"]]></subreportExpression>
	</subreport>
</detail>

The following is a full sample of the data sent by Squore and fed into the report template. Note that this data is only created in memory and not saved to disk when generating a report in Squore. This sample is provided to help you understand how the JasperReports template locates data to extract and format in the final report document.

<?xml version="1.0" encoding="UTF-8"?>
<ReportModelResources appName="Squore"
                      application="Earth"
                      artefactName="Earth"
                      artefactType="Application"
                      author="demo"
                      companyName="Squoring Technologies"
                      companyUrl="http://www.squoring.com/"
                      logo="/path/to/header.image"
                      model="software_analytics"
                      poweredBy="/path/to/poweredBy.image"
                      reportDate="2018.02.27 17:55:54 CET"
                      restoreUrl="${artefactURL}?tabName=default"
                      supportUrl="http://support.squoring.com/"
                      version="V6"
                      versionDate="2017.09.05 01:00:00 CEST">
	<Charts>
		<Chart id="INDICATOR"
		       name="Key Performance Indicator"
		       path="/path/to/chart.image"/>
		<Chart ... />
	</Charts>
	<Tables>
		<Table id="COMPLEXITY_DENSITY"
		       name="Complexity">
			<Line data="10,8 %"
			      evolution="/path/to/trend.image"
			      image="/path/to/level.image"
			      isIcon="true|false"
			      isOnlyText="true|false"
			      name="Ratio of complex modules"/>
			<Line ... />
		</Table>
		<Table ... >
		...
		</Table>
	</Tables>
	<Measures>
		<Measure evolution="↑"
		         id="VG"
		         name="Cyclomatic Complexity"
		         refValue="335"
		         value="453"/>
		<Measure ... />
	</Measures>
	<Indicators>
		<Indicator evolution="/path/to/trendImage.svg"
		           icon="/path/to/icon.svg"
		           id="CPXT"
		           level="Level B"
		           name="Complexity Distribution"
		           refIcon="$/path/to/levelImage.svg"
		           refLevel="Level A">
			<Measure evolution="↑"
				 id="CPXT"
				 name="Complexity Distribution"
				 refValue="0.01"
				 value="0.0.3"/>
		</Indicator>
		<Indicator ... />
	</Indicators>
	<Infos>
		<Info id="LANGUAGE"
		      name="Language"
		      refValue="Multiple"
		      value="Multiple"/>
		<Info ... />
	</Infos>
	<Data>
		<Findings id="VIOLATIONS"
		          total="247"
		          totalDelta="104"
		          type="Findings"
		          url="${artefactURL}?tabName=findings">
			<FindingsDefinition CHARACTERISTIC="Maintainability"
			                    SCALE_NATURE="Non Conformity"
			                    SCALE_REMEDIATION="High"
			                    SCALE_SEVERITY="Critical"
			                    <!-- scales and characteristics according to your analysis model -->
			                    delta="+1"
			                    desc="Functions shall not called themselves either directly or indirectly (see [MISRA-C:2004]: RULE 16.2)."
			                    justif="My relaxation comment"
			                    measureId="R_NORECURSION"
			                    mnemo="NORECURSION"
			                    name="Recursion are not allowed"
			                    occ="1"
			                    toolName="Squan Sources"/>
			<FindingsDefinition ... />
		</Findings>
		<Findings ... >
		...
		</Findings>
		<FindingOccurrences id="FINDINGS"
		                    relaxationState="RELAXED">
			<Artefact name="main(int,char*[])"
			          path="apps/master.c"
			          type="C Function"
			          url="${artefactURL}?tabName=FINDINGS">
				<Finding count="1"
				         id="2064416"
				         line="Ligne: 95"
				         new="true"
				         tool="Squan Sources">
					<Rule externalId="R_COMPOUND"
					      mnemonic="COMPOUND"
					      name="Missing compound statement"/>
					<Relaxation date="2018-01-31T10:08:04"
					            status="Derogation (Imported)"
					            user="demo">keeping some conciseness by avoiding using compound {}</Relaxation>
				</Finding>
				<Finding ... >
				...
				</Finding>
			</Artefact>
		</FindingOccurrences>
		<DefectReports id="AIS">
			<DefectReportsDefinition SCALE_AI_TYPE="Non Regression"
			                         SCALE_PRIORITY="High"
			                         <!-- scales according to your analysis model -->
			                         artefactName="hi_scores_disp(int)"
			                         artefactPath="apps/score.c"
			                         desc="The object hi_scores_disp(int) has a higher number of 'Blocker' or 'Critical' rules violated since the previous version."
			                         id="${ActionItemId}"
			                         measureId="${ActionItemId}"
			                         name="More 'Blocker' or 'Critical' rules violated"
			                         scope="C Function"
			                         since="V6"
			                         status="Open"
			                         url="${artefactURL}?tabName=action-items">
				<Reason desc="Code Status reveals that development is in progress (=1).&#10;"/>
				<Reason ... />
			</DefectReportsDefinition>
			<DefectReportsDefinition ... />
		</DefectReports>
		<Highlights col0="New Code Stability Index"
		            col1="Line Count"
		            filterId="TOP_10_MOST_CHANGED_ARTEFACTS"
		            id="MOST_CHANGED"
		            nbColumns="2"
		            title="Top 10 most changed artefacts">
			<TopArtefact artefactName="print_instructions_fr()"
			             artefactPath="core/write.c"
			             col0="12,5 %"
			             col1="72"
			             rating="/path/to/level.image"
			             url="${artefactURL}?tabName=highlights"/>
			<TopArtefact ... />
		</Highlights>
		<Artefacts id="RELAXED_ARTEFACT"
                   relaxationState="RELAXED">
			<Artefact name="machine.c"
                      path="apps"
                      relaxationComment="Why I relaxed this..."
                      relaxationDate="2018.02.28 16:11:29 CET"
                      relaxationUser="demo"
                      type="C File"/>
			<Artefact ... />
		</Artefacts>
	</Data>
	<SubData>
		<SubArtefacts id="COMPLEX_MODULES">
			<SubArtefact name="machine_plays()"
			             path="apps/machine.c"
			             type="C Function"
			             url="${artefactURL}">
				<!-- Each SubArtefact contains Charts, Tables Measures, Indicators and Infos sections similar to the ones at ReportModelResources level -->
				<Charts>
					<Chart ... />
				</Charts>
				<Tables>
					<Table ... />
				</Tables>
				<Measures>
					<Measure ... />
				</Measures>
				<Indicators>
					<Indicator ... />
				</Indicators>
				<Infos>
					<Info ... />
				</Infos>
			</SubArtefact>
		</SubArtefacts>
	</SubData>
</ReportModelResources>

Note

${artefactURL} is a direct link to open the specified Explorer tab in Squore for the artefact mentioned in the report.