AvoidDeeplyNestedIfStmts - lpohl-Reply/pmd-github-action GitHub Wiki

Rule: AvoidDeeplyNestedIfStmts

Message

Deeply nested if..then statements are hard to read

Description

Avoid creating deeply nested if-then statements since they are harder to read and error-prone to maintain.

Priority

3

Example

public class Foo {
    public void bar(Integer x, Integer y, Integer z) {
        if (x>y) {
            if (y>z) {
                if (z==x) {
                    // !! too deep
                }
            }
        }
    }
}