声纳给了我下面的圈复杂度数:22声纳如何计算圈复杂度?
对于下面的程序:
private static SomeDto checkSomething(AnotherDto anotherDto, String reference)
{
SomeDto someDto = new SomeDto();
// condition 1
if (!someDto.getA())
return new SomeDto("bla1", "blabla");
// condition 2
if (someDto.getName2() == null || checkSurName(anotherDto.getName()))
return new SomeDto("bla2", "blabla");
// condition 3
if (someDto.getName3() == null || checkSurName(anotherDto.getName()))
return new SomeDto("bla3", "blabla");
// condition 4
if (someDto.getName4() == null && checkSurName(anotherDto.getName()))
return new SomeDto("bla4", "blabla");
// condition 5
if (someDto.getName5() == null || checkSurName(anotherDto.getName()))
return new SomeDto("bla5", "blabla");
// condition 6
if (someDto.getName6() == null && checkSurName(anotherDto.getName()))
return new SomeDto("bla6", "blabla");
// condition 7
if (someDto.getName7() == null && checkSurName(anotherDto.getName()))
return new SomeDto("bla7", "blabla");
// condition 8
if (someDto.getName8() == null && checkSurName(anotherDto.getName()))
return new SomeDto("bla8", "blabla");
// condition 9
if (someDto.getName9() == null && checkSurName(anotherDto.getName()))
return new SomeDto("bla9", "blabla");
// condition 10
if (someDto.getName10() == null && checkSurName(anotherDto.getName()))
return new SomeDto("bla10", "blabla");
// condition 11
if (someDto.getName11() == null && checkSurName(anotherDto.getName()))
return new SomeDto("bla11", "blabla");
return someDto;
}
问题我得到的是以下几点:
“这种方法的圈复杂度” checkSomething“是22,它大于12授权”
我的问题是: 考虑Mac Ca (公式)v(g)= e - n + 2,Sonar如何达到22的数量?
其中:
E =边缘
数N =节点
在这个方法中有多少边和节点的有多少? 这种方法的控制流程是什么?
我们在SonarQube版本6.3(建立19869)。
请[编辑]你的问题,包括问题 –
分析仪的名称和版本,你可以发布一个具体的'if(condition *)'? –
是的。 'if(anotherDto.getName()== null ||!checkSurName(anotherDto.getName())) return new SomeDto(“bla10”,“blabla”);' –