49 lines
1.3 KiB
Plaintext
49 lines
1.3 KiB
Plaintext
Shared naming conventions allow teams to collaborate effectively. This rule raises an issue when the brace-style is not respecting the convention setup in parameter:
|
|
|
|
* https://en.wikipedia.org/wiki/Indentation_style#K&R_style[1tbs] (default)
|
|
* https://en.wikipedia.org/wiki/Indentation_style#Allman_style[allman]
|
|
* https://en.wikipedia.org/wiki/Indentation_style#Variant:_Stroustrup[stroustrup]
|
|
|
|
== Noncompliant Code Example
|
|
|
|
Using the parameter default (1tbs):
|
|
|
|
----
|
|
if (condition)
|
|
{ //Noncompliant
|
|
doSomething();
|
|
} //Noncompliant
|
|
else {
|
|
doSomethingElse();
|
|
}
|
|
----
|
|
|
|
== Compliant Solution
|
|
|
|
----
|
|
if (condition) { //Compliant
|
|
doSomething();
|
|
} else { //Compliant
|
|
doSomethingElse();
|
|
}
|
|
----
|
|
|
|
== Exceptions
|
|
|
|
* Object literals appearing as arguments can start on their own line.
|
|
|
|
----
|
|
functionWithObject(
|
|
{ //Compliant
|
|
g: "someValue"
|
|
}
|
|
);
|
|
----
|
|
|
|
|
|
* When blocks are inlined (left and right curly braces on the same line), no issue is triggered.
|
|
|
|
----
|
|
if(condition) {doSomething();} //Compliant
|
|
----
|