coverlet-coverage / coverlet

Cross platform code coverage for .NET
MIT License
2.98k stars 386 forks source link

coverlet-coverage give much higher Cyclomatic Complexity score for given Method then Visual Studio 2022 Code Metrics Results #1554

Open wzaieddev opened 10 months ago

wzaieddev commented 10 months ago

Hi, I'm Trying to generate coverage report, and i get much higher Cyclomatic Complexity score then Visual Studio 2022 Code Metrics Results Method Cyclomatic Complexity score | coverage.cobertura.report ==> 36 Method Cyclomatic Complexity score | Code Metrics Results ==> 19

what is the most reliable value that could i adopt ?

PS: I don't know if it might be relevant or not, with SonarQube i get 19, the same value as Code Metrics Results

Please find below some technical details:

Please find below some technical details:

NET 6 Xunit coverlet.collector => 6.0.0 coverlet.msbuild => 6.0.0 coverage report format => cobertura Attachment: coverage.cobertura.report -> cobertura report Method-SavePaymentNotifyAsync -> Method source code , method name: SavePaymentNotifyAsync Code_Metrics_Results.PNG -> Visual studio screen

Code_Metrics_Results

coverage.cobertura.report.txt

Method-SavePaymentNotifyAsync.txt

Bertk commented 10 months ago

Hi, thank you for this information.

Could you please create a coverage report using ReportGenerator and compare the numbers.

The coverage.cobertura.report.txt has 3 elements for method Method-SavePaymentNotifyAsync and the Cyclomatic Complexity score 18 from class OrdersService is close to the screen shot .

<class name="Vittoria.PaymentGateway.Services.Orders.OrdersService/&lt;SavePaymentNotifyAsync&gt;d__10" filename="Services\PaymentGateway.Services\Orders\OrdersService.cs" line-rate="0.5555" branch-rate="0.6111" complexity="18"/>

<class name="Vittoria.PaymentGateway.Services.CreditCard.CreditCardService/&lt;SavePaymentNotifyAsync&gt;d__12" filename="Services\PaymentGateway.Services\CreditCard\CreditCardService.cs" line-rate="0.7719" branch-rate="0.6388" complexity="36" />

<class name="Vittoria.PaymentGateway.Services.ClepayMyBank.ClepayMyBankService/&lt;SavePaymentNotifyAsync&gt;d__13" filename="Services\PaymentGateway.Services\ClepayMyBank\ClepayMyBankService.cs" line-rate="0.6756" branch-rate="0.6666" complexity="6" />

By the way, I like the SonarQube cognitive complexity metric which is more useful than Cyclomatic Complexity see also Cyclomatic Complexity and Line Numbers.

We do not have the details for the Microsoft.CodeCoverage details but the coverlet implementation.

Please close the issue if you do not have further questions.

github-actions[bot] commented 6 months ago

This issue is stale because it has been open for 3 months with no activity.