This metric even affects other software metrics such as the code maintainability index. Looking at the numbers given per method in the source code, you can figure out whether your code is particularly complex or not. Why is cyclomatic complexity important?īasically, cyclomatic complexity is important because it can help you understand how complex your code is. In a similar manner, in case the source code contains one if condition then cyclomatic complexity will be 2 since there will be two paths, one will be for true and the other will be for false. if second command might immediately follow the first command.Īs an example, if the source code does not contain a control flow statement then its cyclomatic complexity is 1 and the source code contains a single path in it. The nodes in the graph represent the smallest group of commands of a program, and a directed edge in it connects the two nodes i.e. The cyclomatic complexity can be computed by making use of the Control Flow Graph of the program. Essentially, programs that have a lower cyclomatic complexity tend to be easier to understand and less risky to modify. The metric was developed by Thomas McCabe to determine the stability and level of confidence in a program. This software metric is used for the purpose of indicating the complexity of a program. The cyclomatic complexity of a section of code is the quantitative measurement of the number of linearly independent paths that are in it.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |