ERROR: More than one file found with name:

I am running analysis on my Salesforce code in an Azure devops pipeline. The build is triggered by a pull request against the develop branch.
My step tasks for the sonarCloud part of the build are:

- task: SonarCloudPrepare@1
  displayName: 'Prepare SonarCloud engine for code analysis'
  inputs:
    SonarCloud: 'SonarCloud'
    organization: '*my org name*'
    scannerMode: 'CLI'
    configMode: 'manual'
    cliProjectKey: '*my project key*'
    cliProjectName: '*my project key*'
    cliSources: 'force-app/main/default/classes,force-app/main/default/triggers'
    extraProperties: |
      sonar.exclusions=**/*.xml, **/*__*.cls, **/*est.cls, **/*ests.cls, **/?est*.cls, **/SignupTestController.cls

      sonar.apex.coverage.reportPath=$(Build.ArtifactStagingDirectory)/.testresults/test-result-codecoverage.json     

- task: SonarCloudAnalyze@1
  displayName: 'Analyse code with SonarCloud'

- task: SonarCloudPublish@1
  displayName: 'Publish SonarCloud results to SonarCloud project'
  inputs:
    pollingTimeoutSec: '300'

The build runs fine, except there are errors listed in the build. Iget the following error duplicated in the build results:

2020-11-16T04:40:19.1893506Z ##[error]ERROR: More than one file found with name: 'UpdateOpp'
java.lang.IllegalArgumentException: expected one element but was: <force-app/main/default/classes/UpdateOpp.cls, force-app/main/default/triggers/UpdateOpp.trigger>
	at org.sonar.api.batch.fs.internal.DefaultFileSystem.inputFile(DefaultFileSystem.java:114)
	at com.A.A.D.E.A(Unknown Source)
	at com.A.A.D.E.execute(Unknown Source)
	at org.sonar.scanner.sensor.AbstractSensorWrapper.analyse(AbstractSensorWrapper.java:45)
	at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:75)
	at org.sonar.scanner.sensor.ModuleSensorsExecutor.lambda$execute$1(ModuleSensorsExecutor.java:48)
	at org.sonar.scanner.sensor.ModuleSensorsExecutor.withModuleStrategy(ModuleSensorsExecutor.java:66)
	at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:48)
	at org.sonar.scanner.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:68)
	at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:122)
	at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:108)
	at org.sonar.scanner.scan.ProjectScanContainer.scan(ProjectScanContainer.java:438)
	at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:434)
	at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:392)
	at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:122)
	at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:108)
	at org.sonar.scanner.bootstrap.GlobalContainer.doAfterStart(GlobalContainer.java:126)
	at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:122)
	at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:108)
	at org.sonar.batch.bootstrapper.Batch.doExecute(Batch.java:58)
	at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:52)
	at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:46)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:60)
	at com.sun.proxy.$Proxy0.execute(Unknown Source)
	at org.sonarsource.scanner.api.EmbeddedScanner.doExecute(EmbeddedScanner.java:189)
	at org.sonarsource.scanner.api.EmbeddedScanner.execute(EmbeddedScanner.java:138)
	at org.sonarsource.scanner.cli.Main.execute(Main.java:112)
	at org.sonarsource.scanner.cli.Main.execute(Main.java:75)
	at org.sonarsource.scanner.cli.Main.main(Main.java:61)

Obviously the file is not a duplicate as it has different extensions.
The analysis still happens and the results are published to my sonarcloud account for the pull request.

Can you please help me solve this build issue.
Thanks in advance
Peter

Hello @PeterCaitens,

The problem happens during the import of the coverage report. I suspect it to contain something like:

    {
      "id": "12345",
      "name": "UpdateOpp",
      ...
    },

This confuses the importer since this coverage information could refers to both .cls or .trigger files.

At this point, can you confirm that this is what is happening? Which one is the report actually targeting?

Note that this error will result in missing coverage information for this file only, everything else should behave as expected.

Hi Quentin,
Thanks for the reply. Didn’t see it till just now.
The issue is occurring as part of a build pipeline. How would I view what the coverage report contains as the environment disappears at the end of the process.