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
+8-8Lines changed: 8 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,7 +3,7 @@
3
3
## Introduction
4
4
5
5
This document describes how to format the code you contribute to this repository. It covers aspects such as layout, white-space, naming, and documentation. Adhering to consistent standards makes code easier to read and maintain. Of course, these are only guidelines, and can be overridden as the need arises on a case-by-case basis. Where existing code deviates from these guidelines, prefer consistency with the surrounding code.
6
-
Note, if you use [CodeQL for Visual Studio Code](https://help.semmle.com/codeql/codeql-for-vscode/procedures/about-codeql-for-vscode.html), you can autoformat your query in the editor.
6
+
Note, if you use [CodeQL for Visual Studio Code](https://codeql.github.com/docs/codeql-for-visual-studio-code/about-codeql-for-visual-studio-code/), you can autoformat your query in the editor.
7
7
8
8
Words in *italic* are defined in the [Glossary](#glossary).
1. Use [PascalCase](http://wiki.c2.com/?PascalCase) for:
169
+
1. Use [PascalCase](https://wiki.c2.com/?PascalCase) for:
170
170
-`class` names
171
171
-`module` names
172
172
-`newtype` names
@@ -249,7 +249,7 @@ For more information about documenting the code that you contribute to this repo
249
249
1. The `and` and `else` keywords *may* be placed on the same line as the closing parenthesis.
250
250
1. The `and` and `else` keywords *may* be "cuddled": `) else (`
251
251
1.*Always* qualify *calls* to predicates of the same class with `this`.
252
-
2.*Prefer* postfix casts `a.(Expr)` to prefix casts `(Expr)a`.
252
+
1.*Prefer* postfix casts `a.(Expr)` to prefix casts `(Expr)a`.
253
253
254
254
### Examples
255
255
@@ -350,16 +350,16 @@ For more information about documenting the code that you contribute to this repo
350
350
351
351
| Phrase | Meaning |
352
352
|-------------|----------|
353
-
|*[annotation](https://help.semmle.com/QL/ql-handbook/language.html#annotations)*| An additional specifier used to modify a declaration, such as `private`, `override`, `deprecated`, `pragma`, `bindingset`, or `cached`. |
353
+
|*[annotation](https://codeql.github.com/docs/ql-language-reference/ql-language-specification/#annotations)*| An additional specifier used to modify a declaration, such as `private`, `override`, `deprecated`, `pragma`, `bindingset`, or `cached`. |
354
354
|*body*| The text inside `{ }`, `( )`, or each section of an `if`-`then`-`else` or `from`-`where`-`select`. |
355
355
|*binary operator*| An operator with two operands, such as comparison operators, `and`, `or`, `implies`, or arithmetic operators. |
356
356
|*call*| A *formula* that invokes a predicate, e.g. `this.isStatic()` or `calls(a,b)`. |
357
-
|*[conjunct](https://help.semmle.com/QL/ql-handbook/language.html#conjunctions)*| A formula that is an operand to an `and`. |
357
+
|*[conjunct](https://codeql.github.com/docs/ql-language-reference/ql-language-specification/#conjunctions)*| A formula that is an operand to an `and`. |
358
358
|*declaration*| A class, module, predicate, field or newtype. |
359
-
|*[disjunct](https://help.semmle.com/QL/ql-handbook/language.html#disjunctions)*| A formula that is an operand to an `or`. |
360
-
|*[formula](https://help.semmle.com/QL/ql-handbook/language.html#formulas)*| A logical expression, such as `A = B`, a *call*, a *quantifier*, `and`, `or`, `not`, `in` or `instanceof`. |
359
+
|*[disjunct](https://codeql.github.com/docs/ql-language-reference/ql-language-specification/#disjunctions)*| A formula that is an operand to an `or`. |
360
+
|*[formula](https://codeql.github.com/docs/ql-language-reference/ql-language-specification/#formulas)*| A logical expression, such as `A = B`, a *call*, a *quantifier*, `and`, `or`, `not`, `in` or `instanceof`. |
361
361
|*should/should not/avoid/prefer*| Adhere to this rule wherever possible, where it makes sense. |
362
362
|*may/can*| This is a reasonable alternative, to be used with discretion. |
363
363
|*must/always/do not*| Always adhere to this rule. |
364
-
|*[quantifier/aggregation](https://help.semmle.com/QL/ql-handbook/language.html#aggregations)*|`exists`, `count`, `strictcount`, `any`, `forall`, `forex` and so on. |
364
+
|*[quantifier/aggregation](https://codeql.github.com/docs/ql-language-reference/ql-language-specification/#aggregations)*|`exists`, `count`, `strictcount`, `any`, `forall`, `forex` and so on. |
365
365
|*variable*| A parameter to a predicate, a field, a from variable, or a variable introduced by a *quantifier* or *aggregation*. |
Copy file name to clipboardExpand all lines: docs/query-help-style-guide.md
+34-33Lines changed: 34 additions & 33 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,11 +4,12 @@
4
4
5
5
When you contribute a new [supported query](supported-queries.md) to this repository, or add a custom query for analysis in LGTM, you should also write a query help file. This file provides detailed information about the purpose and use of the query, which is available to users in LGTM (for example [here](https://lgtm.com/rules/1506093386171/)) and on the query homepages:
@@ -18,57 +19,57 @@ Query help files must have the same base name as the query they describe and mus
18
19
19
20
Query help files are written using a custom XML format, and stored in a file with a `.qhelp` extension. The basic structure is as follows:
20
21
21
-
```
22
+
```xml
22
23
<!DOCTYPEqhelp SYSTEM "qhelp.dtd">
23
24
<qhelp>
24
25
CONTAINS one or more section-level elements
25
26
</qhelp>
26
27
```
27
28
28
-
The header and single top-level `<qhelp>` element are both mandatory.
29
+
The header and single top-level `<qhelp>` element are both mandatory.
29
30
30
31
### Section-level elements
31
32
32
33
Section-level elements are used to group the information within the query help file. All query help files should include at least the following section elements, in the order specified:
33
34
34
-
1.`overview`—a short summary of the issue that the query identifies, including an explanation of how it could affect the behavior of the program.
35
-
2.`recommendation`—information on how to fix the issue highlighted by the query.
36
-
3.`example`—an example of code showing the problem. Where possible, this section should also include a solution to the issue.
37
-
4.`references`—relevant references, such as authoritative sources on language semantics and best practice.
35
+
1.`overview`—a short summary of the issue that the query identifies, including an explanation of how it could affect the behavior of the program.
36
+
2.`recommendation`—information on how to fix the issue highlighted by the query.
37
+
3.`example`—an example of code showing the problem. Where possible, this section should also include a solution to the issue.
38
+
4.`references`—relevant references, such as authoritative sources on language semantics and best practice.
38
39
39
-
For further information about the other section-level, block, list and table elements supported by query help files, see [Query help files](https://help.semmle.com/QL/learn-ql/ql/writing-queries/query-help.html) on help.semmle.com.
40
+
For further information about the other section-level, block, list and table elements supported by query help files, see [Query help files](https://codeql.github.com/docs/writing-codeql-queries/query-help-files/) on codeql.github.com.
40
41
41
42
42
43
## English style
43
44
44
45
You should write the overview and recommendation elements in simple English that is easy to follow. You should:
45
46
46
-
*Use simple sentence structures and avoid complex or academic language.
47
-
*Avoid colloquialisms and contractions.
48
-
*Use US English spelling throughout.
49
-
*Use words that are in common usage.
47
+
* Use simple sentence structures and avoid complex or academic language.
48
+
* Avoid colloquialisms and contractions.
49
+
* Use US English spelling throughout.
50
+
* Use words that are in common usage.
50
51
51
52
## Code examples
52
53
53
54
Whenever possible, you should include a code example that helps to explain the issue you are highlighting. Any code examples that you include should adhere to the following guidelines:
54
55
55
-
*The example should be less than 20 lines, but it should still clearly illustrate the issue that the query identifies. If appropriate, then the example may also be runnable.
56
-
*Put the code example after the recommendation element where possible. Only include an example in the description element if absolutely necessary.
57
-
*If you are using an example to illustrate the solution to a problem, and the change required is minor, avoid repeating the whole example. It is preferable to either describe the change required or to include a smaller snippet of the corrected code.
58
-
*Clearly indicate which of the samples is an example of bad coding practice and which is recommended practice.
59
-
*Define the code examples in `src` files. The language is inferred from the file extension:
56
+
* The example should be less than 20 lines, but it should still clearly illustrate the issue that the query identifies. If appropriate, then the example may also be runnable.
57
+
* Put the code example after the recommendation element where possible. Only include an example in the description element if absolutely necessary.
58
+
* If you are using an example to illustrate the solution to a problem, and the change required is minor, avoid repeating the whole example. It is preferable to either describe the change required or to include a smaller snippet of the corrected code.
59
+
* Clearly indicate which of the samples is an example of bad coding practice and which is recommended practice.
60
+
* Define the code examples in `src` files. The language is inferred from the file extension:
60
61
61
-
```
62
-
<example>
63
-
<p>This example highlights poor coding practice</p>
62
+
```xml
63
+
<example>
64
+
<p>This example highlights poor coding practice</p>
64
65
65
-
<sample src = "example-code-bad.java" />
66
+
<sample src = "example-code-bad.java" />
66
67
67
-
<p>This example shows how to fix the code</p>
68
+
<p>This example shows how to fix the code</p>
68
69
69
-
<sample src = "example-code-fixed.java" />
70
-
</example>
71
-
```
70
+
<sample src = "example-code-fixed.java" />
71
+
</example>
72
+
```
72
73
73
74
Note, if any code words are included in the `overview` and `recommendation` sections, they should be formatted with `<code> ... </code>` for emphasis.
74
75
@@ -90,7 +91,7 @@ Note, & symbols need to be replaced by \&. The symbol will be displayed corr
90
91
91
92
### Academic papers
92
93
93
-
If you are citing an academic paper, we recommend adopting the reference style of the journal that you are citing. For example:
94
+
If you are citing an academic paper, we recommend adopting the reference style of the journal that you are citing. For example:
94
95
95
96
>S. R. Chidamber and C. F. Kemerer, _A metrics suite for object-oriented design_. IEEE Transactions on Software Engineering, 20(6):476-493, 1994.
96
97
@@ -109,11 +110,11 @@ For example:
109
110
110
111
If your query checks code for a CWE weakness, you should use the `@tags` element in the query file to reference the associated CWEs, as explained [here](query-metadata-style-guide.md). When you use these tags, a link to the appropriate entry from the [MITRE.org](https://cwe.mitre.org/scoring/index.html) site will automatically appear as a reference in the output HTML file.
111
112
112
-
## Query help example
113
+
## Query help example
113
114
114
-
The following example is a query help file for a query from the standard query suite for Java:
115
+
The following example is a query help file for a query from the standard query suite for Java:
0 commit comments