SonarCloud analyze fails to parse file but task i success?!?!?

  • ALM Azure DevOps
  • CI Azure DevOps
  • ARM template so mostly json
  • Steps to reproduce have an invalid json file
  • Potential workaround: None

We are trying to scan our ARM templates which are jsonfiles.
I was very surprised to see the SonarQube analyze is successfull even if it (the analyze task) get the following error
##[error]14:19:10.013 ERROR Cannot parse ‘PathToAJSONFile.json’

We are using SonarCloud to avoid getting currupt files/code in the repo, so why doesnt SonarCloudAnalyze@3 fail on an error?
I’ve added continueOnError: false

Hey @Pontus,

By default, SonarQube does not fail the analysis if a file cannot be parsed. There are various reasons why not all files parse correctly, including new language constructs that SonarQube may not have updated for, or files that aren’t meant to represent production code and contain errors.

If you analyze 1,000 files, and 1 file fails to parse, it seems better to log a warning than to fail the whole process and prevent you from getting any analysis results.

There is a rule for each language to track parsing failures. You can enable this rule and set the severity high enough to impact your Quality Gate if that is important to you. If this is the case, it will fail the build if you fail the pipeline when the quality gate fails.