Executing SonarLint CLI from within PDSOE

Introduction

Since release 1.9.8 the OpenEdge plugins for SonarSource support execution from SonarLint for CLI. Using the steps described below it is possible to execute SonarLint from Progress Developer Studio - providing a workaround for the not yet available support for SonarLint for Eclipse.

Sample SolarLint Report

Configuration

sonarlint.p

The procedure Consultingwerk/Studio/SonarLintLauncher/sonarlint.p supports execution of the SonarLint CLI for files currently selected in Progress Developer Studio (a single file or a complete folder with all sub-folders).

The procedure is intended to be launched from a PCTRun task as it's retrieving it's parameters from PCTRun. Supported parameters:

ParameterDescription
sonarlintInstallation Directory of the Sonarlint CLI
SelectedFileThe full pathname of the selected file or folder - ${selected_resource_loc}
sourceEncodingThe sourcecodes code page
dlcThe OpenEdge installation directory
propathThe PROPATH required to analyze the source
databasesComma delimited list of .df files required for analyzing the sourcecoude

ANT script

An ANT script is required to execute the procedure sonarlint.p via PCTRun.

The sample ANT script needs to be adjusted to match your current environment.

The taskdef reference needs to point to a PCT.jar file (the PCT ANT plugin). The Parameter's section of the PCTRun tag needs to meet the required parameter values of the sonarlint.p procedure (see above).

In this sample script, all parameters are expected to be passed via the ant command line (-D parameters).

Sample sonarlint.xml ANT script
<?xml version="1.0" encoding="utf-8"?>

<project name="SmartComponent Library" default="SonarSource"
    basedir="." xmlns:sonar="antlib:org.sonar.ant">

    <description>SmartComponent Library</description>

    <property environment="env" />
    <property file="build/build.props" />

    <!-- Définition des tâches externes -->
    <taskdef resource="PCT.properties" classpath="/Progress/PCT116/ant/lib/PCT.jar" />
    
    <target name="sonarlint">
        
        <PCTRun procedure="Consultingwerk/Studio/SonarLintLauncher/sonarlint.p" 
            graphicalMode="true" dlcHome="${progress.DLC}" cpinternal="iso8859-1" cpstream="iso8859-1"
            compileUnderscore="true" inputchars="2000000" token="4000" tempDir="c:\temp">

            <Parameter name="sonarlint" value="${sonarlint}"/>
            <Parameter name="SelectedFile" value="${SelectedFile}"/>
            <Parameter name="sourceEncoding" value="${sourceEncoding}"/>
            <Parameter name="dlc" value="${dlc}"/>
            <Parameter name="propath" value="${propath}"/>
            <Parameter name="databases" value="${databases}"/>
        </PCTRun>    
    
    </target>
</project>    

Eclipse External Tools Launch Configuration

The Eclipse External Tools Launch Configuration configures how the ANT script is invoked from within Progress Developer Studio.

To create the launch configuration, open the External Tools Configurations dialog and create a new ANT Build configuration with the following settings.

SettingDescription
NameThe name for the External Tools Run Configuration
BuildfileYou ANT script, based on above example
Base DirectoryThe sourcecode's project root
Arguments

-Dsonarlint=c:\Progress\sonarlint-cli
-DSelectedFile=${selected_resource_loc}
-DsourceEncoding=iso8859-1
-Ddlc=/Progress/OpenEdge116_64
-Dpropath=.,src,Consultingwerk/Studio/ProdictDumpHack/src,OERA
-Ddatabases=../DB/build/SmartDB/smartdb.df,../DB/build/icfdb/icfdb.df,../DB/build/Sports2000/sports2000.df

Refresh resources upon completionChecked, Specific resources, select the .sonarlint directory in your project root folder, available after first run only
Common → Save asShared File, specify a file name to share this configuration with team mates

Executing the ANT script

To execute the ANT script from Progress Developer Studio, select the resource to analyse (a single sourcecode file or a whole folder in the resource view.

Then execute the external tools configuration.

The Script will be executed, output is provided in the console view.

The SonarLint report can be found in the .sonarlint/sonarlint-report.html file.