Please provide
- Operating system: Windows 11 Pro
- Visual Studio version: 18.2.1
- SonarQube for Visual Studio plugin version: 9.5.0.16100
- Programming language you’re coding in: C++17
- Is connected mode used: no.
- SonarQube Cloud, SonarQube Server, or SonarQube Community Build? (if one of the latter two, which version?):
And a thorough description of the problem / question:
I have code similar to the following code:
if (std::string s1, s2, s3; foo(input, “param1”, s1) && foo(input, “param2”, s2) && foo(input, “param3”, s3)) {
…
}
with foo being a function with the signature bool foo(const std::string& input, const char* name, std::string& out). Essentially, the function checks if it finds the text given in parameter name and if it does, it extracts the corresponding string, puts it in the variable out and returns true, otherwise it returns false and does nothing with variable out.
The variable input is a std::string.
At the moment SonarQube marks the if statement with cpp:S1659 and when clicking the quickfix, SonarQube converts it to:
if (std::string s1;
std::string s2;
std::string s3; foo(input, “param1”, s1) && foo(input, “param2”, s2) && foo(input, “param3”, s3)) {
…
}
which is incorrectly formatted c++ code.