Hi,
We use SonarQube Developer Edition latest version which means 9.9 version. Visual Studio 2022 was upgraded to 17.5.0 at Feb 23, 2023. After this date, cognitive complexity issues were marked automatically as Close(Fixed). But issues still are in the code.
BTW, We use Azure DevOps pipelines. When I checked the log of the pipelines. I saw this exception in Run Code Anaylsis Step. This exception was thrown almost all lines.
WARN: Skipping the import of Visual Studio XML code coverage for the invalid file path: D:\a\1\s\Prometheus.NetStandard\SummaryImpl\SampleBuffer.cs at line 769866
java.io.IOException: The device is not ready
at java.base/java.io.WinNTFileSystem.canonicalize0(Native Method)
at java.base/java.io.WinNTFileSystem.canonicalize(WinNTFileSystem.java:465)
at java.base/java.io.File.getCanonicalPath(File.java:626)
at org.sonar.plugins.dotnet.tests.VisualStudioCoverageXmlReportParser$Parser.handleSourceFileTag(VisualStudioCoverageXmlReportParser.java:110)
at org.sonar.plugins.dotnet.tests.VisualStudioCoverageXmlReportParser$Parser.dispatchTags(VisualStudioCoverageXmlReportParser.java:77)
at org.sonar.plugins.dotnet.tests.VisualStudioCoverageXmlReportParser$Parser.parse(VisualStudioCoverageXmlReportParser.java:63)
at org.sonar.plugins.dotnet.tests.VisualStudioCoverageXmlReportParser.accept(VisualStudioCoverageXmlReportParser.java:45)
at org.sonar.plugins.dotnet.tests.VisualStudioCoverageXmlReportParser.accept(VisualStudioCoverageXmlReportParser.java:32)
at org.sonar.plugins.dotnet.tests.CoverageCache.readCoverageFromCacheOrParse(CoverageCache.java:39)
at org.sonar.plugins.dotnet.tests.CoverageAggregator.mergeParsedCoverageWithAggregatedCoverage(CoverageAggregator.java:142)
at org.sonar.plugins.dotnet.tests.CoverageAggregator.aggregate(CoverageAggregator.java:133)
at org.sonar.plugins.dotnet.tests.CoverageAggregator.aggregate(CoverageAggregator.java:120)
at org.sonar.plugins.dotnet.tests.CoverageReportImportSensor.analyze(CoverageReportImportSensor.java:92)
at org.sonar.plugins.dotnet.tests.CoverageReportImportSensor.execute(CoverageReportImportSensor.java:84)
at org.sonar.scanner.sensor.AbstractSensorWrapper.analyse(AbstractSensorWrapper.java:64)
at org.sonar.scanner.sensor.ProjectSensorsExecutor.execute(ProjectSensorsExecutor.java:52)
at org.sonar.scanner.scan.SpringProjectScanContainer.doAfterStart(SpringProjectScanContainer.java:371)
at org.sonar.core.platform.SpringComponentContainer.startComponents(SpringComponentContainer.java:188)
at org.sonar.core.platform.SpringComponentContainer.execute(SpringComponentContainer.java:167)
at org.sonar.scanner.bootstrap.SpringGlobalContainer.doAfterStart(SpringGlobalContainer.java:137)
at org.sonar.core.platform.SpringComponentContainer.startComponents(SpringComponentContainer.java:188)
at org.sonar.core.platform.SpringComponentContainer.execute(SpringComponentContainer.java:167)
at org.sonar.batch.bootstrapper.Batch.doExecute(Batch.java:72)
at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:66)
at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:46)
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
at java.base/java.lang.reflect.Method.invoke(Method.java:578)
at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:60)
at jdk.proxy1/jdk.proxy1.$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:126)
at org.sonarsource.scanner.cli.Main.execute(Main.java:81)
at org.sonarsource.scanner.cli.Main.main(Main.java:62)
In my pipeline, Visual Studio Test step generate one .coverage file. In the next powershell step, we generate a new .coveragexml file. We use the below command
& C:\agent2\_work\_tool\VsTest\17.5.0\x64\tools\net462\Team Tools\Dynamic Code Coverage Tools\CodeCoverage.exe analyze /output:$(Agent.TempDirectory)\TestResults\CoverageResult.coveragexml C:\agent2\_work\_temp\TestResults\9cbd363e-9e76-41e0-ad3c-4524b98c1f71\filename_2023-03-28.06_57_15.coverage
After this command step, Sonarqube Code Analysis step runs and analyzes $(Agent.TempDirectory)\TestResults\CoverageResult.coveragexml
file.
Before Visual Studio 2022 upgrading, The pipelines used old Code Coverage.exe. It was version 17.4.1
Our issue graph
So, what will we do to solve this problem?