Why is cyclomatic Complexity of Switch Block 2?

Switch Block has two possible outcomes: input 1 or input 3. The cyclomatic complexity of the block should have been 1 according to its defination in the documentation .
Why does the Simulink check API (slmetrics) return 2 instead of 1. Am i missing something ?

 Réponse acceptée

Fangjun Jiang
Fangjun Jiang le 20 Juil 2020

1 vote

A Switch block is an equivilant of an if-else statement. Its cyclomatic complexity number is 2.

3 commentaires

Logically it makes sense to have CC =2 . But according the description on the documentation, I am unsure if it is coherent with the cyclomatic complexity defination by Mathworks
Fangjun Jiang
Fangjun Jiang le 27 Juil 2020
Good point! Contact the Mathworks tech support and ask to explain the cases of a Switch block and a multi-port Switch block, i.e. what is N and "On". It seems the documetation has error.
They updated the documentation based on my feedback.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Simulink dans Centre d'aide et File Exchange

Produits

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by