SonarCloud Not Picking Up Issues from Flake8 Report in Azure DevOps Pipeline

I have configured an Azure DevOps pipeline where I run Flake8 for Python linting. The Flake8 results are written to a file named flake8.txt. I am attempting to integrate these Flake8 results into my SonarCloud analysis, but SonarCloud does not seem to be picking up the issues reported by Flake8.

Here is a snippet of the relevant part of my Azure pipeline YAML configuration:

  - task: SonarCloudPrepare@1
    displayName: 'Prepare analysis on SonarCloud'
    inputs:
      SonarCloud: 'THSonarCloud'
      organization: 'my_org'
      scannerMode: 'CLI'
      configMode: 'manual'
      cliProjectKey: 'my_project_key'
      cliProjectName: 'my_project_name'
      cliSources: '.'
      extraProperties: |
        sonar.inclusions=my_source_files
        sonar.python.flake8.reportPaths=flake8.txt

I have verified the path specifications and ensured that flake8.txt is in the proper format. Despite this, SonarCloud is not reflecting the Flake8 issues in the code analysis.

Could anyone help me understand why this might be happening and how I can resolve it?

Hey there.

What do the analysis logs say about the import of the report?

INFO: Sensor Import of Flake8 issues [python]
INFO: Sensor Import of Flake8 issues [python] (done) | time=1ms

This is what it says:

INFO: Sensor Import of Flake8 issues [python]
WARN: Failed to resolve 4 file path(s) in Flake8 report. No issues imported related to file(s): ./config/db_config.py;./import_module.py;./utility.py;./utils/crypto.py
INFO: Sensor Import of Flake8 issues [python] (done) | time=178ms

Well that’s something!

Can you post your full Azure Pipelines configuration? It should show the steps that actually generate the flake8 report, which should be generated fresh each build (not stored in the repo, for example).

- script: | 
    flake8 --output-file=flake8.txt
    cat flake8.txt
    ls flake8.txt
  displayName: "Install Flake8 and generate report"

- task: SonarCloudPrepare@1
  displayName: 'Prepare analysis on SonarCloud'
  inputs:
    ...
    extraProperties: |
      ...
      sonar.python.flake8.reportPaths=flake8.txt


Thanks.

Are these the only 4 file paths referenced in your Flake8 report, or are there file paths that succeed at being resolved?