Scanning YAML files throw an error

Must-share information (formatted with Markdown):

  • which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension)
  • how is SonarQube deployed: zip, Docker, Helm
  • what are you trying to achieve
  • what have you tried so far to achieve this

Do not share screenshots of logs – share the text itself (bonus points for being well-formatted)!

  • which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension) - It’s the SQ task on Azure DevOps
  • how is SonarQube deployed: zip, Docker, Helm - Docker
  • what are you trying to achieve - There is an error when scanning YAML files.
  • what have you tried so far to achieve this - Excluded YAML from scanning

We are using SQ with Azure DevOps and we’re scanning a repo that is not a project repo as such, it has a bunch of Py, Shell and PS1 scripts, and a bunch of YAML for K8S deployments. The issue is that SQ scans everything else but cannot the YAML files. This is what’s thrown:

##[error]java.lang.UnsupportedOperationException: Can not add the same measure twice on Metrics/****db-storage.yaml: DefaultMeasure[component=Metrics/****db-storage.yaml,metric=Metric[uuid=<null>,key=ncloc_data,description=<null>,type=DATA,direction=0,domain=<null>,name=ncloc_data,qualitative=false,userManaged=false,enabled=true,worstValue=<null>,bestValue=<null>,optimizedBestValue=false,hidden=false,deleteHistoricalData=false,decimalScale=<null>],value=1=1;2=1;3=1;4=1;5=1;6=1;7=1;8=1;9=1;10=1;11=1,fromCore=false,storage=org.sonar.scanner.sensor.DefaultSensorStorage@2f59f157,saved=false]

The only way to get around this is by excluding YAML (in extraProperties in Prepare task), like this: sonar.exclusions=**/*.xml,**/*.csv,**/*.css,**/*.png,**/*.yaml

But I noticed despite this, in the report sent to SQ Portal, under IssuesLanguages, I see Python, Shell and also YAML. Why is this?

Hey there.

The important version value here would be the version of SonarQube being used. You can find this in the footer of your SonarQube instance.

Sorry, my bad. It’s Enterprise EditionVersion 10.3 (build 82913)

Thanks!

Do you have any community-supported plugins installed on your SonarQube instance?

We probably do. Could that be conflicting? I cannot find it out as yet because I am not the administrator and I would need to get a hold of him, so it will take me some time.

Yes. For example, you’d want to make sure you’re using the latest version of Releases · sbaudoin/sonar-yaml · GitHub

Thanks, I will look into it. Much appreciated.

Hello there. I see the following plugins installed:

  1. Ansible Lint
  2. OpenID Connect Authentication for SonarQube
  3. ShellCheck Analyzer
  4. YAML Analyzer

Looks like YAML Analyzer needs to be updated. It’s at 1.7.0 now, and 1.9.1 is available.

Also, I didn’t find Releases · sbaudoin/sonar-yaml (github.com) in my SQ portal…

Hello there. Just wanted to follow up on this. Any idea what is causing the issue I am facing? Also, it is safe to update YAML Analyzer without breaking anything?

Hey there.

These are all great questions to ask the maintainer of the YAML plugin! That said, I wouldn’t anticipate upgrading a minor version of the YAML plugin would mess anything up. At the very least, you’ll be using a version that officially supports SonarQube v9.9 LTS.