Skip to content

Getting started

Gilles QUERRET edited this page Dec 13, 2016 · 61 revisions

SonarQube installation

  • A quick installation guide is available here.
  • The full installation guide is available here.
  • Please note that the OpenEdge plugin is only supported on 5.6 LTS version.

When SonarQube 5.6 is up and running, you can download and install the OpenEdge plugin and Riverside rules from https://github.com/Riverside-Software/sonar-openedge/releases/latest. Installation is done by dropping the JAR files in $SONAR_HOME/extensions/downloads. After having restarting SonarQube, you should see the plugins in the Update Center : img/updatecenter.png

Getting an evaluation licence for the commercial rules

A server ID is mandatory to execute the commercial rules, so follow the instructions to generate a server ID. If you don't plan to execute commercial rules, you can safely skip this step.

In order to get an evaluation licence, please send an email to contact@riverside-software.fr with:

  • Your name and contact details
  • Your company name
  • The server ID

You'll receive an answer in the next 24 hours.

Build process using Ant and PCT

The OpenEdge plugins only work if you build your applications using Ant and PCT, as they expect a specific directory structure for the build directories. Describing how to setup Ant and PCT builds is out of the scope of this document.

First step - Build

<PCTCompile destdir="target/build" listing="true" xmlXref="true" keepXref="true" relativePaths="true">
  <fileset dir="src/openedge" includes="**/*.p,**/*.w,**/*.cls" />
  <propath location="src/openedge" />
  <DBConnection dbName="xxx" dbDir="db" singleUser="true" />
</PCTCompile>

Please note that standard XREF files are not analyzed, only XML XREF are.

Second step - Unit tests

You can use any framework to execute unit tests, but getting code coverage requires generating profiler output. This can achieved with the Profiler attribute in PCT :

<!-- A simple example using PCTRun, but you can use ABLUnit, ProUnit or OEUnit -->
<PCTRun procedure="unit-tests/test-suite.p">
  <propath location="target/build" />
  <!-- Use dedicated directory for profiler output -->
  <Profiler enabled="true" outputDir="target/profiler" coverage="true" />
  <DBConnection dbName="xxx" dbDir="db" singleUser="true" />
</PCTRun>

This example will generate a profiler file (including coverage information) for each session in the profiler directory.

Third step - Execute SonarRunner or Sonar Ant task

Write a .properties file in order to describe the project to SonarQube:

sonar.projectKey=companyName:projectKey         # Unique key for SQ
sonar.projectName=Project name                  # Display name in SQ
sonar.projectVersion=x.y.z                      #
sonar.projectDescription=...
sonar.sources=dump,src/openedge                 # Comma-separated list of directories - Dump contains .df files, and src/openedge contains source code
sonar.exclusions=src/procedures/sample/excl/**  # Comma-separated list of patterns to be excluded
sonar.sourceEncoding=iso8859-1
sonar.oe.binaries=target/build                  # Directory where r-code can be found
sonar.oe.propath=src/openedge                   # Comma-separated list of PL or directories
sonar.oe.dlc=/path/to/dlc                       # DLC installation path (see next property)
sonar.oe.propath.dlc=true                       # Append $DLC/gui, $DLC/tty and $DLC/src to the propath
sonar.oe.databases=dump/sp2k.df                 # Comma-separated list of full DF files
sonar.oe.aliases=sp2k,db1,db2                   # Semi colon separated list of entries, each entry is a comma-separated list of aliases (first entry is the db name)
sonar.cpd.exclusions=dump/**                    # No Copy-Paste Detection on DF files
sonar.oe.cpd.debug=false                        # Set to true to generate token listing in .tokens subdirectory
sonar.oe.proparse.debug=false                   # Set to true to generate AST for each file in .proparse subdirectory
# sonar.oe.file.suffixes=p,w,t                  # Default extensions are .p, .w, .i and .cls. Use this option if you have additional extensions to analyze
sonar.oe.coverage.profiler.dirs=target/profiler # Comma-separated list of directories where *.out files will be parsed for code coverage

Analysis can then be triggered either with command-line SonarQube scanner or with SonarQube scanner Ant task. Please note that the Maven plugin can't be used with OpenEdge projects.

The list of properties is described here.

Clone this wiki locally