Skip to content

Latest commit

 

History

History
38 lines (29 loc) · 694 Bytes

NestedForLoop.md

File metadata and controls

38 lines (29 loc) · 694 Bytes

Pattern: Nested for loop

Issue: -

Description

Reports classes with nested for loops.

Example of violations:

for (int i = 0; i < 100; ++i) {
for (int j = 0; j < 100; ++j) { // violation
    println i + j
}
}

for (int i = 0; i < 100; ++i) {
for (int j = 0; j < 100; ++j) { // violation
    println i + j
}
for (int j = 0; j < 100; ++j) { // violation
    println i + j
}
}

for (int i = 0; i < 100; ++i) {
for (int j = 0; j < 100; ++j) { // violation
    for (int k = 0; k < 100; ++k) { // violation
        println i + j + k
    }
}
}

Further Reading