1.2.756. Nested Ifthen

Three levels of ifthen is too much. The method should be split into smaller functions.

<?php

function foo($a, $b) {
    if ($a == 1) {
        // Second level, possibly too much already
        if ($b == 2) {

        }
    }
}

function bar($a, $b, $c) {
    if ($a == 1) {
        // Second level.
        if ($b == 2) {
            // Third level level.
            if ($c == 3) {
                // Too much
            }
        }
    }
}

?>

Name

Default

Type

Description

nestedIfthen

3

integer

Maximal number of acceptable nesting of if-then structures

See also No title for Structures/TooManyIf.

1.2.756.1. Specs

Short name

Structures/NestedIfthen

Rulesets

All, Analyze

Exakat since

0.8.4

PHP Version

All

Severity

Major

Time To Fix

Quick (30 mins)

Precision

Very high

Features

if-then

Examples

LiveZilla, MediaWiki

Available in

Entreprise Edition, Exakat Cloud