Skip to content

STY020 too-complex ​

warning opt-in

A procedure's cyclomatic complexity exceeds 10.

Why ​

Cyclomatic complexity counts the independent paths through a procedure (1 + each if, else if, do, case, type/rank guard). Above about 10 (McCabe's threshold) a procedure is hard to test path by path and hard to read; split it into smaller procedures. Nested procedures are measured separately.

Reported ​

fortran
subroutine update_everything(...)   ! 25 branches

Preferred ​

fortran
! one procedure per step, each with a few branches

Suppressing ​

For one occurrence, with the reason on the same line (or alone on the line before the statement):

fortran
! fobis: ignore[STY020] <why this occurrence is fine>

For the whole project, ignore = STY020 in the fobos [lint] section.

Equivalent ​

Fortitude rule S901 (see Lint Rules).