This project has moved and is read-only. For the latest updates, please go here.

Complexity calculator Visual Studio extension

Calculating complexity

The metric shows the number of branches a method may contain.

If a method contains no code, it’ll have complexity value of 1 – only one flow is possible for the method:

public void M() { int x = 0; }

If a method contains an if statement, then the code has two possible flows and the complexity value will be 2:

public void M(int x) { if (x > 1) { x++; } return x; }

If a method contains an if statement and the method has complex condition, the method complexity will be higher. For example, this method complexity is 3:

public void M(int x) { if (x > 1 && x < 100) { x++; } return x; }

Last edited Jul 1, 2011 at 10:18 PM by es_eof, version 6


No comments yet.