83 lines
1.7 KiB
Plaintext
Raw Normal View History

== Why is this an issue?
2020-06-30 12:47:33 +02:00
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]
2020-06-30 12:47:33 +02:00
=== Noncompliant code example
2020-06-30 12:47:33 +02:00
Using the parameter default (1tbs):
2022-02-04 17:28:24 +01:00
[source,javascript]
2020-06-30 12:47:33 +02:00
----
if (condition)
{ //Noncompliant
doSomething();
} //Noncompliant
else {
2020-06-30 12:47:33 +02:00
doSomethingElse();
}
----
=== Compliant solution
2020-06-30 12:47:33 +02:00
2022-02-04 17:28:24 +01:00
[source,javascript]
2020-06-30 12:47:33 +02:00
----
if (condition) { //Compliant
doSomething();
} else { //Compliant
doSomethingElse();
}
----
=== Exceptions
2020-06-30 12:47:33 +02:00
* Object literals appearing as arguments can start on their own line.
[source,javascript]
2020-06-30 12:47:33 +02:00
----
functionWithObject(
{ //Compliant
g: "someValue"
}
);
----
* When blocks are inlined (left and right curly braces on the same line), no issue is triggered.
[source,javascript]
2020-06-30 12:47:33 +02:00
----
if(condition) {doSomething();} //Compliant
----
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
include::../message.adoc[]
=== Parameters
.braceStyle
****
----
1tbs
----
enforced brace-style: 1tbs, stroustrup or allman.
****
'''
== Comments And Links
(visible only on this page)
include::../comments-and-links.adoc[]
endif::env-github,rspecator-view[]