How do I test the Cyclomatic complexity of my function?

Luigi Pizza (6120 points)
11 20 65
asked Oct 31, 2021 in Programming in Python by Luigi Pizza (6,120 points)
recategorized Nov 1, 2021 by andrea.sterbini
Is there a way to calculate our function cyclomatic complexity without submitting it?
205 views

4 Answers

Best answer
ruben.ciranni (4650 points)
7 13 31
answered Nov 1, 2021 by ruben.ciranni (4,650 points)
selected Nov 2, 2021 by andrea.sterbini

After installing the radon library (conda install -c conda-forge radon) use the following command inside  the directory of the program you want to analyse:

radon cc -a -s --show-closures program.py

B
BesMorgan (2950 points)
1 2 16
answered Oct 31, 2021 by BesMorgan (2,950 points)
Sure you’ll find all the information here. Link below.

https://radon.readthedocs.io/en/latest/intro.html#cyclomatic-complexity

Good luck !
KilianS (3590 points)
5 9 27
commented Nov 2, 2021 by KilianS (3,590 points)
thanks, appreciate that
andrea.sterbini (172780 points)
513 935 1789
answered Oct 31, 2021 by andrea.sterbini (172,780 points)
We compute the maximum cyclomatic complexity of the submitted functions

Use radon
christian.gennarelli (1130 points)
1 2 7
answered Nov 1, 2021 by christian.gennarelli (1,130 points)

You can find the right command here: https://q2a.di.uniroma1.it/21928/software-and-required-libraries?show=21928#q21928&course=advices/programming-ay21-22 under "Other useful commands" at the line "To compute the code intricacy (maximum cyclomatic complexity)".