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: docs/ql-style-guide.md
+14-6Lines changed: 14 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -54,6 +54,7 @@ select c, "This call to '$@' is deprecated because " + reason + ".",
54
54
- Immediately after `if`, `then`, or `else` keywords. The `then` and `else` parts *should* be consistent.
55
55
1.*Avoid* other line breaks in declarations, other than to break long lines.
56
56
1. When operands of *binary operators* span two lines, the operator *should* be placed at the end of the first line.
57
+
1. If the parameter list needs to be broken across multiple lines then there must *must* be a line break after the opening `(`, the parameter declarations indented one level, and the `) {` on its own line at the outer indentation.
57
58
58
59
### Examples
59
60
@@ -65,9 +66,11 @@ private int getNumberOfParameters() {
1. Write the `and` at the end of the line. This also applies in `where` clauses.
287
290
1.*Prefer* to write the `or` keyword on its own line.
288
-
1. The `or` keyword *may* be written at the end of a line, or within a line, provided that it has no unparenthesised `and` operands.
291
+
1. The `or` keyword *may* be written at the end of a line, or within a line, provided that it has no `and` operands.
289
292
1. Single-line formulas *may* be used in order to save space or add clarity, particularly in the *body* of a *quantifier/aggregation*.
290
293
1.*Always* use brackets to clarify the precedence of:
291
294
-`implies`
292
295
-`if`-`then`-`else`
296
+
1.*Avoid* using brackets to clarify the precedence of:
297
+
-`not`
298
+
-`and`
299
+
-`or`
293
300
1. Parenthesised formulas *can* be written:
294
301
- Within a single line. There *should not* be an additional space following the opening parenthesis or preceding the closing parenthesis.
295
302
- Spanning multiple lines. The opening parenthesis *should* be placed at the end of the preceding line, the body should be indented one level, and the closing bracket should be placed on a new line at the outer indentation.
296
303
1.*Quantifiers/aggregations**can* be written:
297
304
- Within a single line. In this case, there is no space to the inside of the parentheses, or after the quantifier keyword.
298
-
- Across multiple lines. In this case, type declarations are on the same line as the quantifier, the `|`*may* be at the end of the line, or *may* be on its own line, and the body of the quantifier *must* be indented one level. The closing `)` is written on a new line, at the outer indentation.
305
+
- Across multiple lines. In this case, type declarations are on the same line as the quantifier with the `|` at the end of the same line as the quantifier, the second `|`*must* be at the end of the same line as the quantifier or on its own line at the outer indentation, and the body of the quantifier *must* be indented one level. The closing `)` is written on a new line, at the outer indentation. If the type declarations need to be broken across multiple lines then there must *must* be a line break after the opening `(`, the type declarations indented one level, and the first `|` on its own line at the outer indentation.
299
306
1.`if`-`then`-`else`*can* be written:
300
307
- On a single line
301
308
- With the *body* after the `if`/`then`/`else` keyword
0 commit comments