"The main branch has no lines of code" analyzing Python repository

Please find below details:

  • Using SonarQube CE 10.1.0.73491, Sonar Scanner 4.8.0.2856
  • Using BitBucket Repository containing Python codes in the main branch.

The overview screen post analyzing shows: The main branch has no lines of code
and the Code Screen show: No code files were found for analysis.

Need help to understand why this is happening even when there are multiple Python files in the repository.

Hey there.

What do the analysis logs say?

INFO: Scanner configuration file: C:\Users\PranshuGupta\Downloads\sonarScanner project\sonar-scanner-4.8.0.2856-windows\bin..\conf\sonar-scanner.properties
INFO: Project root configuration file: NONE
INFO: SonarScanner 4.8.0.2856
INFO: Java 11.0.17 Eclipse Adoptium (64-bit)
INFO: Windows 10 10.0 amd64
INFO: User cache: C:\Users\PranshuGupta.sonar\cache
INFO: Analyzing on SonarQube server 10.1.0.73491
INFO: Default locale: “en_IN”, source code encoding: “windows-1252” (analysis is platform dependent)
INFO: Load global settings
INFO: Load global settings (done) | time=104ms
INFO: Server id: 147B411E-AYm_5XPi_q797dRBWtDL
INFO: User cache: C:\Users\PranshuGupta.sonar\cache
INFO: Load/download plugins
INFO: Load plugins index
INFO: Load plugins index (done) | time=82ms
INFO: Load/download plugins (done) | time=282ms
INFO: Process project properties
INFO: Process project properties (done) | time=9ms
INFO: Execute project builders
INFO: Execute project builders (done) | time=1ms
INFO: Project key: des_development_team_de-mdm-python-integration_AYm_7e-ZB-TrfNolzzRG
INFO: Base dir: C:\Users\PranshuGupta\Downloads\sonarScanner project\sonar-scanner-4.8.0.2856-windows\bin
INFO: Working dir: C:\Users\PranshuGupta\Downloads\sonarScanner project\sonar-scanner-4.8.0.2856-windows\bin.scannerwork
INFO: Load project settings for component key: ‘des_development_team_de-mdm-python-integration_AYm_7e-ZB-TrfNolzzRG’
INFO: Load project settings for component key: ‘des_development_team_de-mdm-python-integration_AYm_7e-ZB-TrfNolzzRG’ (done) | time=30ms
WARN: SCM provider autodetection failed. Please use “sonar.scm.provider” to define SCM of your project, or disable the SCM Sensor in the project settings.
INFO: Load quality profiles
INFO: Load quality profiles (done) | time=277ms
INFO: Load active rules
INFO: Load active rules (done) | time=3371ms
INFO: Load analysis cache
INFO: Load analysis cache (404) | time=20ms
INFO: Load project repositories
INFO: Load project repositories (done) | time=28ms
INFO: Indexing files…
INFO: Project configuration:
INFO: 2 files indexed
INFO: ------------- Run sensors on module des_development_team_de-mdm-python-integration_AYm_7e-ZB-TrfNolzzRG
INFO: Load metrics repository
INFO: Load metrics repository (done) | time=27ms
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=5ms
INFO: Sensor CSS Rules [javascript]
INFO: No CSS, PHP, HTML or VueJS files are found in the project. CSS analysis is skipped.
INFO: Sensor CSS Rules [javascript] (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=30ms
INFO: Sensor C# Properties [csharp]
INFO: Sensor C# Properties [csharp] (done) | time=1ms
INFO: Sensor HTML [web]
INFO: Sensor HTML [web] (done) | time=5ms
INFO: Sensor TextAndSecretsSensor [text]
INFO: Sensor TextAndSecretsSensor [text] (done) | time=11ms
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=27ms
INFO: Sensor VB.NET Properties [vbnet]
INFO: Sensor VB.NET Properties [vbnet] (done) | time=0ms
INFO: Sensor IaC Docker Sensor [iac]
INFO: 0 source files to be analyzed
INFO: 0/0 source files have been analyzed
INFO: Sensor IaC Docker Sensor [iac] (done) | time=111ms
INFO: ------------- Run sensors on project
INFO: Sensor Analysis Warnings import [csharp]
INFO: Sensor Analysis Warnings import [csharp] (done) | time=1ms
INFO: Sensor Zero Coverage Sensor
INFO: Sensor Zero Coverage Sensor (done) | time=4ms
INFO: SCM Publisher No SCM system was detected. You can use the ‘sonar.scm.provider’ property to explicitly specify it.
INFO: CPD Executor Calculating CPD for 0 files
INFO: CPD Executor CPD calculation finished (done) | time=0ms
INFO: Analysis report generated in 102ms, dir size=129.6 kB
INFO: Analysis report compressed in 32ms, zip size=15.3 kB
INFO: Analysis report uploaded in 127ms
INFO: Note that you will be able to access the updated dashboard once the server has processed the submitted analysis report
INFO: Analysis total time: 7.753 s
INFO: ------------------------------------------------------------------------
INFO: EXECUTION SUCCESS
INFO: ------------------------------------------------------------------------
INFO: Total time: 9.767s
INFO: Final Memory: 18M/67M
INFO: ------------------------------------------------------------------------

That doesn’t seem like many… and this doesn’t look like where your project files will be located:

You should execute the scanner while in the folder of the project you want to analyze. Typically this is done by adding the folder containing sonar-scanner to your PATH variable.