Wrong Code Smell Issue getting produced in sonarqube server :: cpp:S5523

Hello Team,

Getting wrong code smell issue in our sonarqube server even after local variable is initialized after declaration. Refer attached screenshot.

Code Smell :: Major
Rule: Local variables should be initialized immediately cpp:S5523
Sonarqube server version: Enterprise Edition - Version 9.9.1 LTS

Actually, the variable initialization is done immediately right after declaration. Please check and suggest, how to fix it.

1 Like

Hello @muthusamy.ir.

I apologize for the late reply. It seems your message’s felt through the cracks…

The behavior you experience is unexpected. To investigate what is going on, could you share with me a reproducer, please?

To generate the reproducer file:

  • Search in the analysis log for the full path of the source file for which you want to create a reproducer (for instance, a file that contains a false-positive). You will have to use exactly this name (same case, / or \…)
  • Add the reproducer option to the scanner configuration:
    sonar.cfamily.reproducer="Full path to the .cpp"
  • Re-run the scanner to generate a file named sonar-cfamily-reproducer.zip in the project folder.
  • Please share this file. If you think this file contains private information, let us know, and we’ll send you a private message that will allow you to send it privately.

Thanks