Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 30 additions & 9 deletions rules/S134/apex/rule.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,47 @@ The following example demonstrates the behavior of the rule with the default thr

[source,apex]
----
switch on i { // Compliant - depth = 1
when 1 {
if (i == 1) // Compliant - depth = 1
/* ... */
for (Integer j = 0; j < 10; j++) { // Compliant - depth = 2
/* ... */
for (Integer i = 0, j = 0; i < 10; i++) { // Compliant - depth = 2
Integer k = j + 1;
if (k == 3) { // Compliant - depth = 3, not exceeding the limit
/* ... */
Integer j = i + 1;
if (j == 0){// Compliant - depth = 3, not exceeding the limit
while (k < 10) { // Noncompliant - depth = 4
/* ... */
while (j < 10){ // Noncompliant - depth = 4
if (k == 1) { // Depth = 5, exceeding the limit, but issues are only reported on depth = 4
/* ... */
if (j == 1){ // Depth = 5, exceeding the limit, but issues are only reported on depth = 4
/* ... */
}
}
}
}
}
}
----

==== Compliant solution

[source,apex]
----
if (i != 1) {
return;
}
for (Integer j = 0; j < 10; j++) { // Compliant - depth = 1
/* ... */
Integer k = j + 1;
if (k != 3) {
continue;
}
/* ... */
while (k < 10) { // Compliant - depth = 2
/* ... */
if (k == 1) { // Compliant - depth = 3
/* ... */
}
}
}
----

include::../resources.adoc[]

ifdef::env-github,rspecator-view[]
Expand Down
Loading