You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: modules/ROOT/pages/styleguide.adoc
+10-12Lines changed: 10 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,10 +10,7 @@ The purpose of the Cypher styleguide is to make queries as easy to read as possi
10
10
For rules and recommendations for naming of labels, relationship types and properties, please see the xref::syntax/naming.adoc[Naming rules and recommendations].
11
11
12
12
The best way to make sure your queries follow the styling rules is to use `cypherfmt`, the official Cypher formatter.
13
-
It is available as part of the https://marketplace.visualstudio.com/items?itemName=neo4j-extensions.neo4j-for-vscode[Neo4j VS Code Extension],
14
-
and as a command line tool through the https://www.npmjs.com/package/@neo4j-cypher/language-support[Neo4j Cypher Language Support npm package].
15
-
16
-
13
+
It is available as part of the https://marketplace.visualstudio.com/items?itemName=neo4j-extensions.neo4j-for-vscode[Neo4j VS Code Extension], and as a command line tool through the https://www.npmjs.com/package/@neo4j-cypher/language-support[Neo4j Cypher Language Support npm package].
17
14
18
15
[[cypher-styleguide-general-recommendations]]
19
16
== General recommendations
@@ -24,7 +21,6 @@ and as a command line tool through the https://www.npmjs.com/package/@neo4j-cyph
24
21
For example: `toString()`.
25
22
* If you are storing Cypher statements in a separate file, use the file extension `.cypher`.
26
23
27
-
28
24
[[cypher-styleguide-indentation-and-line-breaks]]
29
25
== Indentation and line breaks
30
26
@@ -121,8 +117,9 @@ WHERE EXISTS { (a)-->(b:B) }
121
117
RETURN a.prop
122
118
----
123
119
124
-
* Limit line length to 80 characters if possible. Line breaks should be applied starting from the outermost group, with each nested group breaking
125
-
until either the line fits or no more line breaks can be inserted. Add two spaces of indentation for each nested broken group.
120
+
* Limit line length to 80 characters if possible.
121
+
Line breaks should be applied starting from the outermost group, with each nested group breaking until either the line fits or no more line breaks can be inserted.
122
+
Add two spaces of indentation for each nested broken group.
126
123
127
124
.Bad
128
125
[source, cypher]
@@ -145,7 +142,7 @@ WHERE
145
142
RETURN n
146
143
----
147
144
148
-
* Start ORDER BY and LIMIT clauses on new lines.
145
+
* Start `ORDER BY` and `LIMIT` clauses on new lines.
149
146
150
147
.Bad
151
148
[source, cypher]
@@ -163,7 +160,8 @@ ORDER BY n.prop
163
160
LIMIT 10
164
161
----
165
162
166
-
* A group containing a CASE expression should always split, and each WHEN, ELSE, and END should be put on a new line. Additionally, WHEN and ELSE should add two spaces of indentation.
163
+
* A group containing a `CASE` expression should always break, and each `WHEN`, `ELSE`, and `END` should be put on a new line.
164
+
Additionally, `WHEN` and `ELSE` should add two spaces of indentation.
167
165
168
166
.Bad
169
167
[source, cypher]
@@ -180,11 +178,11 @@ RETURN
180
178
CASE
181
179
WHEN n.age >= 18 THEN 'Adult'
182
180
ELSE 'Minor'
183
-
END AS ageGroup-
181
+
END AS ageGroup
184
182
----
185
183
186
-
* Lines that end with a list or map literal and do not fit within the maximum width should leave
187
-
the opening bracket/brace on the previous line and use only two additional spaces of indentation.
184
+
* Lines that end with a list or map literal and do not fit within the maximum width should leave the opening bracket or brace on the preceding line.
185
+
The contents of the literal should be indented two additional spaces from the line where the opening bracket or brace appears.
0 commit comments