rspec/rules/S1108/rule.adoc

61 lines
975 B
Plaintext

== Why is this an issue?
Shared coding conventions make it possible for a team to collaborate efficiently.
This rule makes it mandatory to place a closing curly brace and the next ``++else++``, ``++catch++`` or ``++finally++`` keyword on two different lines.
=== Noncompliant code example
[source,text]
----
public void myMethod() {
if(something) {
executeTask();
} else if (somethingElse) { // Noncompliant
doSomethingElse();
}
else { // Compliant
generateError();
}
try {
generateOrder();
} catch (Exception e) {
log(e);
}
finally {
closeConnection();
}
}
----
=== Compliant solution
[source,text]
----
public void myMethod() {
if(something) {
executeTask();
}
else if (somethingElse) {
doSomethingElse();
}
else {
generateError();
}
try {
generateOrder();
}
catch (Exception e) {
log(e);
}
finally {
closeConnection();
}
}
----