How do I test the Cyclomatic complexity of my function?

Luigi Pizza (6110 points)
11 19 65
asked Oct 31, 2021 in Programming in Python by Luigi Pizza (6,110 points)
recategorized Nov 1, 2021 by andrea.sterbini
Is there a way to calculate our function cyclomatic complexity without submitting it?
155 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 (3460 points)
5 8 27
commented Nov 2, 2021 by KilianS (3,460 points)
thanks, appreciate that
andrea.sterbini (169260 points)
490 900 1734
answered Oct 31, 2021 by andrea.sterbini (169,260 points)
We compute the maximum cyclomatic complexity of the submitted functions

Use radon
christian.gennarelli (1130 points)
1 1 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)".