Must-share information (formatted with Markdown):
-
which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension)
sonarqube enterprise lts 9.9 -
how is SonarQube deployed: zip, Docker, Helm
docker -
what are you trying to achieve
“‘break’ will never be executed” bug can not be found for merge request analysis.
But it could be found by a branch analysis. I think it is a bug for 9.9. -
what have you tried so far to achieve this
I have reproduced this issue by sample code.
For example:
#include <iostream>
using namespace std;
void foo(int type)
{
switch(type)
{
case 1:
cout << "type = 1" << endl;
break;
case 2:
cout << "type = 2" << endl;
return; //this line will report "'break' will never be executed" bug in branch analysis
break;
default:
cout << "type = " << type << endl;
break;
}
return;
}
int main()
{
int input = 0;
cout << "input a num:" << endl;
cin >> input;
foo(input);
return 0;
}
=======================================
if I add some lines in dev1 branch, and create a merge request for code changes.
We expected same code pattern should report the same issue: “‘break’ will never be executed” .
But it seems Merge request analysis have NOT report it (FN). Is it a known issue?
void foo(int type)
{
switch(type)
{
case 1:
cout << "type = 1" << endl;
return; // expected report bug but not by merge request analysis
break;
case 2:
cout << "type = 2" << endl;
return;
break;
default:
cout << "type = " << type << endl;
return; // expected report bug but not by merge request analysis
break;
}
return;
}
Do not share screenshots of logs – share the text itself (bonus points for being well-formatted)!