Professional Documents
Culture Documents
R20
JBC S o n a r Q u b e Pl u gi n
Amendment History:
Revisio
Date Amended Name Description
n
1 19th May 2017 JN. Charpin Initial version
2 30th May 2017 JN. Charpin Minor amendment
3 4th May 2018 JN. Charpin Self deployable artifact
Page 2
JBC S o n a r Q u b e Pl u gi n
C o pyri g h t
Copyright © Temenos Headquarters SA 2009-2020.
All rights reserved.
This document contains proprietary information that is protected by copyright. No part of this document may
be reproduced, transmitted, or made available directly or indirectly to a third party without the express
written agreement of TEMENOS UK Limited. Receipt of this material directly TEMENOS UK Limited
constitutes its express permission to copy. Permission to use or copy this document expressly excludes
modifying it for any purpose, or using it to create a derivative therefrom.
Err a t a a n d C o m m e n t s
If you have any comments regarding this manual or wish to report any errors in the
documentation, please document them and send them to the address below:
Technology Department
Temenos Headquarters SA
2 Rue de l’Ecole-de-Chimie,
CH - 1205 Geneva,
Switzerland
Please include your name, company, address, and telephone and fax numbers, and email
address if applicable. TAFJdev@temenos.com
Page 3
JBC S o n a r Q u b e Pl u gi n
Ta b l e o f C o n t e n t s
Copyright................................................................................................................................................ 3
Errata and Comments............................................................................................................................ 3
Introduction........................................................................................................................... 5
Software prerequisites.......................................................................................................... 5
Getting started...................................................................................................................... 7
Lifecycle......................................................................................................................... 14
Options........................................................................................................................... 18
Tunning.......................................................................................................................... 19
Precompiler rules........................................................................................................... 20
Quality profiles............................................................................................................... 22
Troubleshooting.................................................................................................................. 27
Page 4
JBC S o n a r Q u b e Pl u gi n
Intro d u c ti o n
The JBC SonarQube plugin is a Temenos extension to the popular SonarQube (SQ)
continuous code quality platform to provide support for JBC language analysis.
It allows getting metrics, when coding Temenos T24 applications against TAFJ runtime, such
as:
- Code duplication.
This document is not intended to be a complete SQ guide, but a manual to deploy the JBC
plugin, run analysis and parse results.
https://docs.sonarqube.org/display/SONAR/Documentation
S oftw ar e pr er eq ui sit e s
SQ minimal release for R19 JBC Sonar plugin (PB 201806 and higher) is 6.7.3 LTS.
https://www.sonarqube.org/downloads/
SonarQube scanner 3.X and higher or Maven 3 depending on the analysis mode used.
https://docs.sonarqube.org/display/SCAN/Analyzing+with+SonarQube+Scanner
Oracle JDK 8 (a JRE is sufficient for SQ but JDK is required for JBC compilation to Java).
https://docs.sonarqube.org/display/SONAR/Requirements
Page 5
JBC S o n a r Q u b e Pl u gi n
JBC P l u g i n i n s t a l l a t i o n
https://docs.sonarqube.org/display/SONAR/Installing+the+Server
$SonarQube_Home/extensions/plugins
To validate that the JBC plugins has been successfully installed, browse SQ Administration
page, General Settings.
i.e.
http://localhost:9000/settings
http://localhost:9000/settings?category=jbc
Getti n g s t art e d
Page 6
JBC S o n a r Q u b e Pl u gi n
To get started with your first JBC project analysis you could use the demo provided within the
JbcSonarPlugin distribution.
JbcSonarPlugin/demo
It contains a sample JBC component project TI_SonarTest and some configurations files to
run a SQ scanner analysis.
U si n g s o n ar s c a n n er
Installation and configuration
Please refer to following documentation for more information about installing and analysing
using the sonar scanner.
https://docs.sonarqube.org/display/SCAN/Analyzing+with+SonarQube+Scanner
To be able to run the full component build analysis, including JBC component compilation, a
modification to the sonar scanner is required since sonar scanner version 3 and higher to
do not use the embedded JRE as a JDK is required.
sonar-scanner-3.1.0.1141-windows\bin\sonar-scanner.bat
the property
set use_embedded_jre=false
sonar-scanner-3.1.0.1141-linux/bin/sonar-scanner
the property
use_embedded_jre=false
Since the batch file is amended your environment must define a valid java JDK 8 version.
Page 7
JBC S o n a r Q u b e Pl u gi n
Please note that you have to replace "\" by "/" on Windows when defining a path.
Please refer to the configuration section to get more details about project properties.
Once the sonar project is configured an analysis could be triggered by running from the
project root directory the sonar-scanner batch.
i.e.
Page 8
JBC S o n a r Q u b e Pl u gi n
….
On first execution on verbose mode you will notice a stack trace as the project being
analysed doesn’t exist yet.
Page 9
JBC S o n a r Q u b e Pl u gi n
We will detail in the Configuration section what occurs during this build.
As mentioned in the console you should be able to browse the analysis result.
Page 10
JBC S o n a r Q u b e Pl u gi n
Please refer to following documentation for more information about installing and analysing
using the maven sonar scanner.
https://docs.sonarqube.org/display/SCAN/Analyzing+with+SonarQube+Scanner+for+Maven
The maven project configuration is defined within the pom.xml file within the TI_SonarTest
project.
Page 11
JBC S o n a r Q u b e Pl u gi n
The notion of sonar project used with sonar scanner in the section above is now replaced by
the notion of maven project. The important thing to note is that properties used are the same.
Please refer to the configuration section to get more details about project properties.
Page 12
JBC S o n a r Q u b e Pl u gi n
As mentioned in the console you should be able to browse the analysis result.
Page 13
JBC S o n a r Q u b e Pl u gi n
C o n f i g u r a t i o n a n d lif e c y l e
The same properties than the one demonstrated in the demo TI_TestSonar project are
available in the Administration section. They allow changing the analysis behaviour.
http://localhost:9000/settings?category=jbc
These are global properties, but they can be refined on a per project basis, either through the
sonar-project.properties file or the pom.xml in case of maven project as seen in the Getting
started section. Before going into properties details, let’s define the analysis lifecycle.
Lif e c y c l e
The JBC plugin lifecycle is the following depending on the project settings:
- Run the component build sensor if enabled to perform static JBC code analysis,
execute unit tests and compute code coverage.
- Run the issue sensor to generate issues based either on existing issue report
(component build sensor execution) or precompiler sensor.
Page 14
JBC S o n a r Q u b e Pl u gi n
- Run the coverage sensor if coverage report is available (component build sensor
execution or existing report).
Page 15
JBC S o n a r Q u b e Pl u gi n
Page 16
JBC S o n a r Q u b e Pl u gi n
General properties
Key: sonar.jbc.duplication
Default: true
Enable code duplication analysis, memory consuming in case of large project with high duplication
rate. Appropriate heap size must be set at scanner and sonarqube platform level.
Key: sonar.jbc.component.build
Default: true
Full component build: compiles components, run unit tests, compute code coverage and run JBC
static code analysis.
Key: sonar.jbc.file.suffixes
Default: .b
Key: sonar.jbc.precompiler.check
Page 17
JBC S o n a r Q u b e Pl u gi n
Default: false
Precompiler check: run JBC static code analysis - do not run when component build is enabled.
Do not execute unit tests nor code coverage.
Key: sonar.jbc.precompiler.check.non.component
Default: false
Precompiler check parameter: run JBC static code analysis even for non-componentized JBC
code (files with no $PACKAGE).
Options
Key: sonar.jbc.component.build.args
Key: sonar.jbc.precompiler.report.path
Path used by the JBC precompiler to flush analysis reports. Defaulted to '$
{sonar.jbc.tafj.home}/jbcPrecompilerReport' when undefined.
Key: sonar.jbc.component.build.threads
Key: sonar.jbc.coverage.instance
Name of the code coverage instance used during components build. Defaulted to '$
{sonar.jbc.component.project}' when undefined.
Key: sonar.jbc.coverage.port
Code coverage instance port number. A code coverage instance is started during a components
build and communicates coverage data to the coverage receiver.
Default: 7474
Key: sonar.jbc.coverage.report
Code coverage report path. Generated during component build and used during code coverage
analysis. Defaulted to '${sonar.jbc.tafj.home}/CodeCoverageReceiver/data/$
{sonar.jbc.coverage.instance}/coverage.ser' when undefined.
Key: sonar.jbc.coverage.receiver.port
Code coverage receiver port number. Used during components build. There is one unique
coverage receiver which can handle multiple coverage instances.
Default: 7470
Page 18
JBC S o n a r Q u b e Pl u gi n
Key: sonar.jbc.tafj.home
Path used to store and access TAFJ build files, analysis reports and logs. Defaulted to project
working directory when undefined sonar.working.directory when using sonar scanner or maven
build directory.
Tu n n i n g
In case of a full component build has already been performed on another platform or part of
another process, same analysis metrics can be computed with the following setup:
sonar.jbc.component.build=false
sonar.jbc.precompiler.check=true
sonar.jbc.coverage.report=/path/to/coverage.ser
Page 19
JBC S o n a r Q u b e Pl u gi n
R u l e s , q u a l i t y p r o f i l e s a n d jb c r a t i n g
Pr e c o m pil er rul e s
Precompiler rules are based on JBC_Precompiler.jar artefact.
Please refer to the precompiler documentation for more details about these rules.
http://localhost:9000/coding_rules#languages=jbc|tags=jbc-precompiler
Page 20
JBC S o n a r Q u b e Pl u gi n
C u s t o m r u l e s fr o m t e m p l a t e s .
Some of these rules are “templates” which allow creating custom check based on their
parameters.
JBC rule templates could be displayed through the options “Template”->”Show Templates
Only” in the Rules menu.
The template “Track uses of disallowed keyword” allows creating a custom check for the
keyword of interest.
By clicking “Custom Rules Create”, templates parameters are displayed and allow the
custom rule creation.
Page 21
JBC S o n a r Q u b e Pl u gi n
Once created the custom rule can be seen within the template.
It simply need to be added to the quality profile used for the analysis.
Q u a l i ty p r o f i l e s
Quality profiles are set of rules which can be defined when running an analysis.
There is one JBC quality profiles defined by default, referencing the precompiler rules.
http://localhost:9000/profiles
Page 22
JBC S o n a r Q u b e Pl u gi n
Since it is the default built in quality profile, default rules cannot be modified.
However it could be extended with the custom rule defined above by creating a new quality
profile and inheriting its default rules.
Ex t e n d i n g t h e b u i l t i n q u a l i ty p r o f i l e
Create a new profile for JBC language from the “Quality Profiles” menu.
It is possible to inherit all rules from the built in quality profile or any existing Either by
changing the parent profile:
Page 23
JBC S o n a r Q u b e Pl u gi n
The newly created quality profile could be become the new default profile for all projects
analysis or be used only for a set of selected projects.
Page 24
JBC S o n a r Q u b e Pl u gi n
Q u a l i ty g a t e a n d JBC r a t i n g
When performing pre-compilation or code parsing during issue sensor execution an
additional metric is being computed for each JBC program.
This is the JBC rating. Please refer to the precompiler documentation for more information
about rating computation.
You could define a quality gate to fail your build based on a certain rating threshold.
http://localhost:9000/quality_gates
i.e.
Next time you will run an analysis, based on the average JBC rating for your project, you will
pass the quality gate or not.
The measures section of the project will display the average rating for the whole project and
for each jbc source file.
http://localhost:9000/dashboard?id=com.temenos.t24%3ATI-SonarTest
Page 25
JBC S o n a r Q u b e Pl u gi n
http://localhost:9000/component_measures?id=com.temenos.t24%3ATI-
SonarTest&metric=jbc_rating_class
http://localhost:9000/component_measures?id=com.temenos.t24%3ATI-
SonarTest&metric=jbc_rating
Page 26
JBC S o n a r Q u b e Pl u gi n
Tr o u b l e s h o o t i n g
S c a n n er m e m o ry s e t u p
In case of large project analysis you can add more memory to the sonar scanner through the
SONAR_SCANNER_OPTS
i.e.
S c a n n er v erb o s e m o d e
Add to the sonar project the following property.
sonar.verbose=true
Page 27