SonarQube Integration#

Lattix Architect and the Lattix Web repository are now integrated with SonarQubeTM. You will be able to view issues, violations, and DSM views inside SonarQube.

Versions tested: SonarQube 6.7, SonarQube 7.2.1 (support for version 7.2.1 added in Lattix 11.1).

Getting Started#

To download the SonarQube integration, please contact Lattix.

Copy the plugin into the sonarqube installdir//extensions/plugins folder. Then restart the SonarQube service.

Configure Lattix Web from SonarQube#

In your web browser, navigate to the Sonarqube config. You may need to login as Administrator to do this. Enter the following values to allow SonarQube to connect to Lattix Web and the repository.

  • Lattix Repository URL

  • Lattix Repository username

  • Lattix Repository password

image0

Running Lattix Analysis#

Once the Lattix SonarQube plugin has been installed you can run Lattix analysis on your code. The Lattix SonarQube integration works best if you already have an existing SonarQube project with source code analysis.

The Plugin requires that the name of the project is the same on both SonarQube and Lattix Web. You can use either the property sonar.projectKey or the property sonar.projectName to specifiy the project name (you cannot use both properties at the same time). The value of the specified property will also be used as the project name in Lattix Web

The following properties are used by the Lattix SonarQube plugin:

Property Name

Description

Required?

sonar.projectBaseDir

Root directory of the project

Yes

sonar.projectKey

Key identifier of the project. Do not specify if sonar.projectName is set

Yes

sonar.projectName

Specify SonaQube project name. Do not specify if sonar.projectKey is set

No

sonar.projectVersion

Version of the project

No

sonar.sources

Directory that contains the source files. Relative to sonar.projectBaseDir. Make sure to include the path to the LDZ file if you wish Lattix plugin to be run.

No

sonar.language

Optionally set to “lattix” to force execution of Lattix Plugin.

No

sonar.lattix.inputs.<module>

Specify the inputs that will be used to for a Lattix project update. The <module> should be replaced with the appropriate Lattix module

No

sonar.lattix.projectVersion

Set the version of the snapshot that will be uploaded to Lattix Repository. If this is not specified sonar.projectVersion must be set.

No

sonar.lattix.projectFile

Path to Lattix LDZ file. This property is optional if sonar.lattix.getProject is set to true.

Yes

sonar.lattix.codeSmellViolations

“true” means violations are treated as “Code Smells”
“false” means violations are treated as “Bugs”

No

sonar.lattix.home

Path to Lattix Architect

Yes

sonar.lattix.getProject

Set to true to retrieve the project from the repository before analysis begins. If set to true, sonar.lattix.projectFile is optional.

No

sonar.lattix.forceOverwrite

If sonar.lattix.getProject and sonar.lattix.projectFile are both set, set sonar.lattix.forceOverwrite to true to allow file to be overwritten.

No


Sample Ant file that runs Lattix SonarQube Plugin#

<project name="ant_test" default="default" basedir="."  xmlns:sonar="antlib:org.sonar.ant">

<target name="default" depends="sonar_test">
</target>

        <target name="sonar_test">
                <taskdef uri="antlib:org.sonar.ant" resource="org/sonar/ant/antlib.xml">
                        <!-- Update the following line, or put the "sonar-ant-task-*.jar" file in your "$HOME/.ant/lib" folder -->
                        <classpath path="./sonarqube-ant-task-2.5.jar" />
                </taskdef>

                <property name="sonar.host.url" value="http://sonarqube_host:9085" />

                <property name="sonar.projectKey" value="AntProject" />
                <property name="sonar.projectVersion" value="1.9.9" />

                <property name="sonar.projectBaseDir" value="."/>
                <property name="sonar.sources" value="./src" />

                <property name="sonar.lattix.home" value="c:/Program Files/Lattix11.0" />
                <property name="sonar.lattix.projectFile" value="./ant.ldz" />

                <!-- Execute the SonarQube analysis -->
                <sonar:sonar />
        </target>
</project>