I do some tests with Visual Studio Code Metrics. As I can calculate the Cyclomatic Complexity, each if
, while
, for
- operators increase the complexity with 1. I have the next simple method:
static bool ContainsNegative(int a, int b, int c, int d)
{
if (a < 0 || b < 0 || c < 0 || d < 0) return false;
return true;
}
But for it, the Cyclomatic Complexity is 5, instead of 2 (1 for the method + 1 for the if
).
My question is - this is because the Code Metrics calculate each condition in if
operator as a different if
? I.e. my method is equivalent to:
static bool ContainsNegative(int a, int b, int c, int d)
{
if (a < 0) return false;
if (b < 0) return false;
if (c < 0) return false;
if (d < 0) return false;
return true;
}
Here is a screen with results:
Also, is there a list with all rules described in details?
Thank you!