I have a question regarding Cyclometric Complexity.

I have a question regarding Cyclometric Complexity.

I'm looking to include a number of metrics in my Browse and Doc It plug-in and I've been researching the above (wikipedia and the metric notes in RAD Studio) and they mention IF statement and later on conditional loops but they are silent on CASE statements.

If an IF statement increases the complexity by 1 should a CASE statement increase the complexity by at least 1 if not more due to the number of branches?

Comments

  1. Getting late on the bandwagon, but basically: if there is a branching, you need to add 1. Case statements are glorified IFs, thus for each you need to add 1 and you also need to add 1 for the default "else".
    Where it gets really interesting is - however - on the cycles: repeat/until ones should increase it by at least 1 (or more, if you have nested if/case statements) but what about things such as While Not Dataset.Eof do ?

    To me, in that case it shouldn't increase because that is part of the normal processing. Obviously, if you have an IF inside, that counts.

    ReplyDelete

Post a Comment