Skip to content

Getting started

Gilles QUERRET edited this page Sep 27, 2016 · 61 revisions

The OpenEdge plugin is only compatible with the LTS version 5.6. A quick installation guide is available here. The full installation guide is available here. 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.

When SonarQube 5.6 is up and running, you can download and install those three plugins :

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. Enabling debugListing is only required if you have unit tests and want to have code coverage metrics.

First step - Standard compilation

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

Second step - Copy debug listing (for code coverage)

Debug listing files are first copied to a different directory, and line numbers removed :

<mkdir dir="srcDbg" />
<copy toDir="srcDbg">
  <fileset dir="build/.dbg" />
  <filterchain>
    <filterreader classname="com.phenix.pct.DebugListingFilterReader" />
  </filterchain>
</copy>

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="sample/test5.p">
  <propath location="build" />
  <Profiler enabled="true" outputDir="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. Code coverage still has to be extracted from the profiler output, and this is done with the GenericCoverage task :

<GenericCoverage destFile="profiler/profiler.xml">
  <fileset dir="profiler" includes="*.txt" />
  <propath location="srcDbg" />
</GenericCoverage>

Please note that in order to execute the GenericCoverage task, you'll need the latest version of PCT : https://github.com/Riverside-Software/pct/releases/tag/v206

Executing SonarRunner or Sonar Ant task

The best analysis is done by splitting the project in two, first part being for standard analysis, second part for debug listing analysis. This can be done by generating two different project files :

sonar.projectKey=companyName:projectKey
sonar.projectName=Project name
sonar.projectVersion=1                          # Or use your Continuous Integration build number
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=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.projectKey=companyName:projectKeyDbg      # Don't re-use projectKey of previous properties file
sonar.projectName=Project name
sonar.projectVersion=1                          # Or use your Continuous Integration build number
sonar.projectDescription=...
sonar.sources=dump,srcDbg                       # Comma-separated list of directories
sonar.exclusions=srcDbg/sample/excl/**          # Comma-separated list of patterns to be excluded
sonar.sourceEncoding=utf-8
sonar.oe.binaries=buildDbg                      # Directory where r-code can be found, just use an empty directory
sonar.oe.propath=srcDbg                         # Comma-separated list of PL or directories
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.oe.skipProparse=true                      # No analysis on debug listing
sonar.cpd.exclusions=dump/**,srcDbg/**          # Copy-paste detector has to be disabled when analysing debug listing files
sonar.genericcoverage.reportPaths=profiler/profiler.xml  # File produced by the GenericCoverage task

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.

Clone this wiki locally