Bug: ARM template (json file) analyses fails when file contains comments

We are using Azure Devops pipelines to analyse our code:

- task: SonarCloudPrepare@2
  inputs:
    SonarCloud: 'SonarCloud'
    organization: '<ORG>'
    scannerMode: 'MSBuild'
    projectKey: '<PROJECT>'
    extraProperties: sonar.verbose=true
- task: SonarCloudAnalyze@2
- task: SonarCloudPublish@2
  inputs:
    pollingTimeoutSec: '300'

During scanning I see the following error:

14:38:04.296 ERROR: Cannot parse 'Common.Infrastructure/Common/Database.json'
SonarCloudAnalyze

The pattern I have been able to find is that this is because of /* comments */ in the json file. This is an Azure Resource Management template which allows to add these comments and I would like to have them there, because they explains some oddities in the template. The ARM template s also work fine on Azure deployment, so Azure Deployment doesn’t mind these comments.

Example:

    "netFrameworkVersion": "v8.0",
    "vnetName": "[variables('vnetName')]"
  },
  /* Workaround: as the hostNameBindings copy loop doesn't allow empty array */
  "dummyHostNameBinding": [
    {
      "Domain": "[concat(parameters('websiteName'), '.azurewebsites.net')]",
      "Thumbprint": "[json('null')]"
    }
  ],

I would propose to support the ability to have comments in the json file. Is this a possibility?

Hi there, @eriksteinebach,

I have recorded your request for future consideration. Thank you for your input!
As a side note, it would be quite a lot of work because those files are parsed as JSON and JSON parsers do not support comments. As you said, they are not allowed in plain JSON…
It is an interesting request, nonetheless!

Denis