60 lines
1.2 KiB
Plaintext
60 lines
1.2 KiB
Plaintext
== Why is this an issue?
|
|
|
|
include::../description.adoc[]
|
|
|
|
=== Noncompliant code example
|
|
|
|
[source,java,diff-id=1,diff-type=noncompliant]
|
|
----
|
|
for (int i = 1; i <= 10; i++) { // Noncompliant; two "continue" statements
|
|
if (i % 2 == 0) {
|
|
continue;
|
|
}
|
|
|
|
if (i % 3 == 0) {
|
|
continue;
|
|
}
|
|
// ...
|
|
}
|
|
----
|
|
|
|
=== Compliant solution
|
|
[source,java,diff-id=1,diff-type=compliant]
|
|
----
|
|
for (int i = 1; i <= 10; i++) {
|
|
if (i % 2 == 0 || i % 3 == 0) {
|
|
continue;
|
|
}
|
|
// ...
|
|
}
|
|
----
|
|
|
|
== Resources
|
|
|
|
=== Documentation
|
|
|
|
* https://docs.oracle.com/javase/specs/jls/se20/html/jls-14.html#jls-14.7[Oracle - Labeled Statements]
|
|
|
|
=== Articles & blog posts
|
|
|
|
* https://softwareengineering.stackexchange.com/questions/185944/java-labels-to-be-or-not-to-be/185945[StackExchange - Java labels. To be or not to be]
|
|
* https://stackoverflow.com/questions/33689466/labels-in-java-bad-practice[StackOverflow - Labels in Java - bad practice?]
|
|
|
|
ifdef::env-github,rspecator-view[]
|
|
|
|
'''
|
|
== Implementation Specification
|
|
(visible only on this page)
|
|
|
|
include::../message.adoc[]
|
|
|
|
include::../highlighting.adoc[]
|
|
|
|
'''
|
|
== Comments And Links
|
|
(visible only on this page)
|
|
|
|
include::../comments-and-links.adoc[]
|
|
|
|
endif::env-github,rspecator-view[]
|