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