1

I have tried lizard and codalyze, but both can't perfectly meet my needs. For example

bool foo(int n) {
    if (n > 10) {
        if (n % 2 == 0) {
            return true;
        }
        else {
            return false;
        }
    }
    else {
        return false;
    }
}

bool foo3(int n) {
    if (n % 2 == 0) {
        return true;
    }
    else {
        return false;
    }
}

bool foo2(int n) {
    if (n > 10) {
        return foo3(n);
    }
    else {
        return false;
    }
}

output of lizard

================================================
  NLOC    CCN   token  PARAM  length  location
------------------------------------------------
      13      3     40      1      13 foo@[email protected]
       8      2     26      1       8 foo3@[email protected]
       8      2     27      1       8 foo2@[email protected]
1 file analyzed.
==============================================================

However, what I hope is that foo2 has the same condition branch complexity as foo. Are there any other tools I can use?

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.