38 lines
890 B
Plaintext
38 lines
890 B
Plaintext
== Why is this an issue?
|
|
|
|
include::description.adoc[]
|
|
|
|
[source,java]
|
|
----
|
|
if (condition) // Noncompliant
|
|
doTheThing();
|
|
doTheOtherThing(); // Was the intent to call this function unconditionally?
|
|
----
|
|
|
|
It becomes even more confusing and bug-prone if lines get commented out.
|
|
|
|
[source,java]
|
|
----
|
|
if (condition) // Noncompliant
|
|
// doTheThing();
|
|
doTheOtherThing(); // Was the intent to call this function conditionally?
|
|
----
|
|
|
|
Indentation alone or together with curly braces makes the intent clear.
|
|
|
|
[source,java]
|
|
----
|
|
if (condition)
|
|
doTheThing();
|
|
doTheOtherThing(); // Clear intent to call this function unconditionally
|
|
|
|
// or
|
|
|
|
if (condition) {
|
|
doTheThing();
|
|
}
|
|
doTheOtherThing(); // Clear intent to call this function unconditionally
|
|
----
|
|
|
|
This rule raises an issue if the line controlled by a conditional has the same indentation as the conditional and is not enclosed in curly braces.
|