rspec/rules/S3973/rule.adoc

38 lines
890 B
Plaintext
Raw Normal View History

== Why is this an issue?
2020-06-30 12:48:39 +02:00
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
----
2020-06-30 12:48:39 +02:00
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.