Typescript files are ignored when “Cyclomatic Complexity” is added to the Quality Gate

Hi Team,

I see that when we add “Cyclomatic Complexity” to the “Quality Gate” then .ts files are not being considered so overall score will be less. We see 1 score for each html and .js files being reported.

If we remove the “Cyclomatic Complexity” from the “Quality Gate” then .ts files are being considered which is making the metric to go high. In this case all files from above scenario (that is .js, html files) and .ts files are being reported.

Could you please let me know what is the reason for above behavior? Also let me know if you need any other details.

Hi @Naveen_kumar,

Could you please give a few more details about the way you analyze your project:

  • do you use Automatic Analysis?
  • if not, which version of the scanner?
  • how is the scanner configured during analysis?
  • any specific project configuration on SonarCloud side?

If by chance, your project is public on your ALM or on SonarCloud, could you please post a link?

1 Like

Hi Clarie,

Sorry for the delayed response.

We are using automatic analysis. No it is not public.

Hi,

I couldn’t reproduce the behavior with a sample project: https://sonarcloud.io/dashboard?id=claire-villard-sonarsource_sample-js-project

The Quality Gate contains a single condition, on overall Cyclomatic Complexity. It has 1 JS and 1 TS file, it is analyzed with Automatic Analysis. The last evaluated Quality Gate contain the complexity for both files (8 for each file, total of 16, causing the condition to fail).

Apart from quality gate, analysis and project configuration are the default ones.

Do you identify some difference between the sample project and your project that could help me locate the root cause?

Hi,

I still can’t reproduce the behavior.
Could you please try to build a small reproducer, and make it public? It will be easier for us to analyze.

Could you please post the logs produced by the Scanner during the analysis of your project?

As a side note, please note that my name is Claire, not “Clarie”.

Thanks,
Claire

Hi Claire,

Make public is not possible. Is there any other way that we can connect and troubleshoot ???

thanks,
Naveen

Hi,

Sorry, my answer wasn’t clear, I meant a new project, created only to reproduce the issue and without any of your private code, to be able to share with us.
I don’t have access to your private code (hopefully).

In parallel, could you please send the logs produced by the Scanner during the analysis:

  • when the complexity is correctly computed
  • and when the complexity is not correctly computed

Feel free to send them to me on a personal message if you prefer to do not post them publicly here.

Thanks,
Claire