Rust code analysis using plugin community-rust

SonarQube Version: Developer Edition Version 9.1 (build 47736)
Scanner: sonar-scanner-cli-4.6.2.2472
Plugin: community-rust v0.0.8

  • what are you trying to achieve
    Have code analysis reports for Rust code imported into SQ using community-rust plugin.

We have managed to:
->Installed community-rust plugin.
->Generate the clippy reports and pass it to SQ analysis using the command below:

steps {
            script{
               def scannerHome = tool 'SonarScanner';
               withSonarQubeEnv(credentialsId: 'sonarq', installationName: 'sonar-premium') {
                  sh "${scannerHome}/bin/sonar-scanner -Dsonar.projectKey=MDRT_alfred -Dsonar.scm.provider=git -Dcommunity.rust.clippy.reportPaths=./clippy.json"
                 }
            }
         }

But SQ reports says that:
The “sq_clippyreport” branch has no lines of code.

Following are the logs of Jenkinsbuild:


*Running on xxxxxxxxxxxxxxxxxxxxxx in /home/jenkins/workspace/drt_alfred_sq_clippyreport*

*[Pipeline] {*

*[Pipeline] script*

*[Pipeline] {*

*[Pipeline] tool*

*Unpacking http:// repo1.maven.org/maven2/org/sonarsource/scanner/cli/sonar-scanner-cli/4.6.2.2472/sonar-scanner-cli-4.6.2.2472.zip to /home/jenkins/tools/hudson.plugins.sonar.SonarRunnerInstallation/SonarScanner on ecs-jenkins-jenkins-sq-java-ci-0jgqq*

*[Pipeline] withSonarQubeEnv*

*Injecting SonarQube environment variables using the configuration: sonar-premium*

*[Pipeline] {*

*[Pipeline] sh*

*+ /home/jenkins/tools/hudson.plugins.sonar.SonarRunnerInstallation/SonarScanner/bin/sonar-scanner -Dsonar.projectKey=MDRT_alfred -Dsonar.scm.provider=git -Dcommunity.rust.clippy.reportPaths=./clippy.json*

*INFO: Scanner configuration file: /home/jenkins/tools/hudson.plugins.sonar.SonarRunnerInstallation/SonarScanner/conf/sonar-scanner.properties*

*INFO: Project root configuration file: NONE*

*INFO: SonarScanner 4.6.2.2472*

*INFO: Java 11.0.13 Oracle Corporation (64-bit)*

*INFO: Linux 4.14.262-200.489.amzn2.x86_64 amd64*

*INFO: User cache: /home/jenkins/.sonar/cache*

*INFO: Scanner configuration file: /home/jenkins/tools/hudson.plugins.sonar.SonarRunnerInstallation/SonarScanner/conf/sonar-scanner.properties*

*INFO: Project root configuration file: NONE*

*INFO: Analyzing on SonarQube server 9.1.0*

*INFO: Default locale: "en", source code encoding: "UTF-8" (analysis is platform dependent)*

*INFO: Load global settings*

*INFO: Load global settings (done) | time=303ms*

*INFO: Server id: 1F0617A3-AXlarbU4bXSYsRZ8yOdC*

*INFO: User cache: /home/jenkins/.sonar/cache*

*INFO: Load/download plugins*

*INFO: Load plugins index*

*INFO: Load plugins index (done) | time=46ms*

*INFO: Load/download plugins (done) | time=4054ms*

*INFO: Loaded core extensions: developer-scanner*

*INFO: Process project properties*

*INFO: Process project properties (done) | time=0ms*

*INFO: Execute project builders*

*INFO: Execute project builders (done) | time=3ms*

*INFO: Project key: MDRT_alfred*

*INFO: Base dir: /home/jenkins/workspace/drt_alfred_sq_clippyreport*

*INFO: Working dir: /home/jenkins/workspace/drt_alfred_sq_clippyreport/.scannerwork*

*INFO: Load project settings for component key: 'MDRT_alfred'*

*INFO: Load project settings for component key: 'MDRT_alfred' (done) | time=20ms*

*INFO: Load project branches*

*INFO: Load project branches (done) | time=35ms*

*INFO: Load project pull requests*

*INFO: Load project pull requests (done) | time=22ms*

*INFO: Load branch configuration*

*INFO: Detected branch/PR in 'Jenkins'*

*INFO: Auto-configuring branch 'sq_clippyreport'*

*INFO: Load branch configuration (done) | time=11ms*

*INFO: Auto-configuring with CI 'Jenkins'*

*INFO: Load quality profiles*

*INFO: Load quality profiles (done) | time=77ms*

*INFO: Auto-configuring with CI 'Jenkins'*

*INFO: Load active rules*

*INFO: Load active rules (done) | time=1748ms*

*INFO: Branch name: sq_clippyreport*

*INFO: Indexing files...*

*INFO: Project configuration:*

*INFO: 0 files indexed*

*INFO: ------------- Run sensors on module MDRT_alfred*

*INFO: Load metrics repository*

*INFO: Load metrics repository (done) | time=29ms*

*INFO: Sensor CSS Rules [cssfamily]*

*INFO: No CSS, PHP, HTML or VueJS files are found in the project. CSS analysis is skipped.*

*INFO: Sensor CSS Rules [cssfamily] (done) | time=1ms*

*INFO: Sensor C# Project Type Information [csharp]*

*INFO: Sensor C# Project Type Information [csharp] (done) | time=1ms*

*INFO: Sensor C# Analysis Log [csharp]*

*INFO: Sensor C# Analysis Log [csharp] (done) | time=120ms*

*INFO: Sensor C# Properties [csharp]*

*INFO: Sensor C# Properties [csharp] (done) | time=0ms*

*INFO: Sensor JavaXmlSensor [java]*

*INFO: Sensor JavaXmlSensor [java] (done) | time=1ms*

*INFO: Sensor VB.NET Project Type Information [vbnet]*

*INFO: Sensor VB.NET Project Type Information [vbnet] (done) | time=1ms*

*INFO: Sensor VB.NET Analysis Log [vbnet]*

*INFO: Sensor VB.NET Analysis Log [vbnet] (done) | time=16ms*

*INFO: Sensor VB.NET Properties [vbnet]*

*INFO: Sensor VB.NET Properties [vbnet] (done) | time=1ms*

*INFO: Sensor JaCoCo XML Report Importer [jacoco]*

*INFO: 'sonar.coverage.jacoco.xmlReportPaths' is not defined. Using default locations: target/site/jacoco/jacoco.xml,target/site/jacoco-it/jacoco.xml,build/reports/jacoco/test/jacocoTestReport.xml*

*INFO: No report imported, no coverage information will be imported by JaCoCo XML Report Importer*

*INFO: Sensor JaCoCo XML Report Importer [jacoco] (done) | time=2ms*

*INFO: Sensor ThymeLeaf template sensor [securityjavafrontend]*

*INFO: Sensor ThymeLeaf template sensor [securityjavafrontend] (done) | time=0ms*

*INFO: Sensor Serverless configuration file sensor [securityjsfrontend]*

*INFO: 0 Serverless function entries were found in the project*

*INFO: 0 Serverless function handlers were kept as entrypoints*

*INFO: Sensor Serverless configuration file sensor [securityjsfrontend] (done) | time=92ms*

*INFO: Sensor AWS SAM template file sensor [securityjsfrontend]*

*INFO: Sensor AWS SAM template file sensor [securityjsfrontend] (done) | time=2ms*

*INFO: Sensor JavaSecuritySensor [security]*

*INFO: Reading type hierarchy from: /home/jenkins/workspace/drt_alfred_sq_clippyreport/.scannerwork/ucfg2/java*

*INFO: Read 0 type definitions*

*INFO: Reading UCFGs from: /home/jenkins/workspace/drt_alfred_sq_clippyreport/.scannerwork/ucfg2/java*

*INFO: No UCFGs have been included for analysis.*

*INFO: Sensor JavaSecuritySensor [security] (done) | time=4ms*

*INFO: Sensor CSharpSecuritySensor [security]*

*INFO: Reading type hierarchy from: /home/jenkins/workspace/drt_alfred_sq_clippyreport/ucfg_cs2*

*INFO: Read 0 type definitions*

*INFO: Reading UCFGs from: /home/jenkins/workspace/drt_alfred_sq_clippyreport/ucfg_cs2*

*INFO: No UCFGs have been included for analysis.*

*INFO: Sensor CSharpSecuritySensor [security] (done) | time=0ms*

*INFO: Sensor PhpSecuritySensor [security]*

*INFO: Reading type hierarchy from: /home/jenkins/workspace/drt_alfred_sq_clippyreport/.scannerwork/ucfg2/php*

*INFO: Read 0 type definitions*

*INFO: Reading UCFGs from: /home/jenkins/workspace/drt_alfred_sq_clippyreport/.scannerwork/ucfg2/php*

*INFO: No UCFGs have been included for analysis.*

*INFO: Sensor PhpSecuritySensor [security] (done) | time=1ms*

*INFO: Sensor PythonSecuritySensor [security]*

*INFO: Reading type hierarchy from: /home/jenkins/workspace/drt_alfred_sq_clippyreport/.scannerwork/ucfg2/python*

*INFO: Read 0 type definitions*

*INFO: Reading UCFGs from: /home/jenkins/workspace/drt_alfred_sq_clippyreport/.scannerwork/ucfg2/python*

*INFO: No UCFGs have been included for analysis.*

*INFO: Sensor PythonSecuritySensor [security] (done) | time=0ms*

*INFO: Sensor JsSecuritySensor [security]*

*INFO: Reading type hierarchy from: /home/jenkins/workspace/drt_alfred_sq_clippyreport/.scannerwork/ucfg2/js*

*INFO: Read 0 type definitions*

*INFO: Reading UCFGs from: /home/jenkins/workspace/drt_alfred_sq_clippyreport/.scannerwork/ucfg2/js*

*INFO: 08:02:21.570977 Building Runtime Type propagation graph*

*INFO: 08:02:21.57352 Running Tarjan on 0 nodes*

*INFO: 08:02:21.574234 Tarjan found 0 components*

*INFO: 08:02:21.57438 Variable type analysis: done*

*INFO: 08:02:21.574798 Building Runtime Type propagation graph*

*INFO: 08:02:21.574975 Running Tarjan on 0 nodes*

*INFO: 08:02:21.575062 Tarjan found 0 components*

*INFO: 08:02:21.575128 Variable type analysis: done*

*INFO: Analyzing 2 ucfgs to detect vulnerabilities.*

*INFO: Taint analysis starting. Entrypoints: 3*

*INFO: Running symbolic analysis for 'JS'*

*INFO: Taint analysis: done.*

*INFO: Sensor JsSecuritySensor [security] (done) | time=567ms*

*INFO: ------------- Run sensors on project*

*INFO: Sensor Zero Coverage Sensor*

*INFO: Sensor Zero Coverage Sensor (done) | time=0ms*

*INFO: SCM Publisher is disabled*

*INFO: CPD Executor Calculating CPD for 0 files*

*INFO: CPD Executor CPD calculation finished (done) | time=0ms*

*INFO: Load New Code definition*

*INFO: Load New Code definition (done) | time=17ms*

*INFO: Analysis report generated in 181ms, dir size=173.5 kB*

*INFO: Analysis report compressed in 11ms, zip size=22.3 kB*

*INFO: Analysis report uploaded in 32ms*

*INFO: ANALYSIS SUCCESSFUL, you can browse xxxxxxxxxxxxxxxxxxxxxx*

*INFO: Note that you will be able to access the updated dashboard once the server has processed the submitted analysis report*

*INFO: More about the report processing at xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*

*INFO: Analysis total time: 7.011 s*

*INFO: ------------------------------------------------------------------------*

*INFO: EXECUTION SUCCESS*

*INFO: ------------------------------------------------------------------------*

*INFO: Total time: 15.483s*

*INFO: Final Memory: 10M/101M*

Hi,

Welcome to the community!

Rust analysis isn’t provided out of the box. You added a plugin to support that, & it’s up to the plugin to count lines of code. So you should check in with the developers of the Community Rust plugin.

 
HTH,
Ann