-
-
Notifications
You must be signed in to change notification settings - Fork 64
What do the coverage values mean?
Code Coverage Summary provides a useful set of statistics to help you improve the quality of your code but what do the values actually mean?
Cyclomatic complexity measures the number of possible paths execution could take through a given method or function. Simple functions that have no branching will have a complexity of 1. A complex method with many different if clauses and / or switch statements will have a much higher complexity score. A general guideline for the complexity of a function or method is that it should be kept under 10 whenever possible and that anything over 30 is probably not maintainable. When analyzing code to look for problem areas, identifying the highest complexity values is often a good place to start.
When analyzing classes with auto-properties, or just many small methods, you'll frequently see many complexity values of 1 because each get and set method will have a complexity value of 1. This makes it difficult to use cyclomatic complexity as a heuristic or benchmark for classes, namespaces, or projects / assemblies. Cyclomatic complexity is only really useful as a method or function measure, it breaks down at class and higher levels.