False positive on cpp 3927

Make sure to read this post before raising a thread here:

Then tell us:

  • What language is this for? c++20
  • Which rule? cpp:$3972ng cpp:S3972 Move this “if” to a new line or add the missing “else”.
  • Why do you believe it’s a false-positive/false-negative? There is no if else on the code
  • Are you using SonarQube - LTS version 9.9
    • SonarLint - VS proferssional17.5.3/6.15.0.67199
      *connected mode with SonarQube

Clearly there is no if else statement on the indicated line.

I can’t reproduce it with a simple example that’s why I have attached a screenshot:

Thanks for raising this issue @Matthieu_Bolt.

I created a ticket to fix it.

Hi @Matthieu_Bolt ,

I would be interested in your complete case because I don’t understand how the generated code ends up resembling this.

Would you mind generating a reproducer file so that we can analyze it?
Either through SonarQube:

  • Search in the analysis log for the full path of the source file for which you want to create a reproducer (the one in the screenshot). 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 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.

Or through Visual Studio and SonarLint: Troubleshooting problems with C or Cpp analysis · SonarSource/sonarlint-visualstudio Wiki · GitHub

Hi, is this fixed in Enterprise Edition Version 9.9 (build 65466)? I couldn’t really tell from the ticket and I see this error as well.