Skip to content

Commit cf80773

Browse files
authored
Merge pull request github#5830 from Marcono1234/marcono1234/guides-link-updates
Docs: Use GitHub links for guides, improve formatting
2 parents 059a5f3 + ab90fe1 commit cf80773

File tree

5 files changed

+120
-118
lines changed

5 files changed

+120
-118
lines changed

docs/ql-style-guide.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
## Introduction
44

55
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.
77

88
Words in *italic* are defined in the [Glossary](#glossary).
99

@@ -166,7 +166,7 @@ private predicate foo(Expr e, Expr p) {
166166
```
167167

168168
## Naming
169-
1. Use [PascalCase](http://wiki.c2.com/?PascalCase) for:
169+
1. Use [PascalCase](https://wiki.c2.com/?PascalCase) for:
170170
- `class` names
171171
- `module` names
172172
- `newtype` names
@@ -249,7 +249,7 @@ For more information about documenting the code that you contribute to this repo
249249
1. The `and` and `else` keywords *may* be placed on the same line as the closing parenthesis.
250250
1. The `and` and `else` keywords *may* be "cuddled": `) else (`
251251
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`.
253253

254254
### Examples
255255

@@ -350,16 +350,16 @@ For more information about documenting the code that you contribute to this repo
350350

351351
| Phrase | Meaning |
352352
|-------------|----------|
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`. |
354354
| *body* | The text inside `{ }`, `( )`, or each section of an `if`-`then`-`else` or `from`-`where`-`select`. |
355355
| *binary operator* | An operator with two operands, such as comparison operators, `and`, `or`, `implies`, or arithmetic operators. |
356356
| *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`. |
358358
| *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`. |
361361
| *should/should not/avoid/prefer* | Adhere to this rule wherever possible, where it makes sense. |
362362
| *may/can* | This is a reasonable alternative, to be used with discretion. |
363363
| *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. |
365365
| *variable* | A parameter to a predicate, a field, a from variable, or a variable introduced by a *quantifier* or *aggregation*. |

docs/qldoc-style-guide.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,11 +124,12 @@ Certain special predicates should be documented consistently.
124124
* The location spans column `startcolumn` of line `startline` to
125125
* column `endcolumn` of line `endline` in file `filepath`.
126126
* For more information, see
127-
* [Locations](https://help.semmle.com/QL/learn-ql/locations.html).
127+
* [Locations](https://codeql.github.com/docs/writing-codeql-queries/providing-locations-in-codeql-queries/).
128128
*/
129129
130130
predicate hasLocationInfo(string filepath, int startline, int startcolumn, int endline, int endcolumn) { ... }
131131
```
132+
132133
## QLDoc for classes
133134

134135
1. Document classes using a noun phrase of the form `A <domain element> that <has property>.`

docs/query-help-style-guide.md

Lines changed: 34 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@
44

55
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:
66

7-
* [C/C++ queries](https://help.semmle.com/wiki/display/CCPPOBJ/)
8-
* [C# queries](https://help.semmle.com/wiki/display/CSHARP/)
9-
* [Java queries](https://help.semmle.com/wiki/display/JAVA/)
10-
* [JavaScript queries](https://help.semmle.com/wiki/display/JS/)
11-
* [Python queries](https://help.semmle.com/wiki/display/PYTHON/)
7+
* [C/C++ queries](https://codeql.github.com/codeql-query-help/cpp/)
8+
* [C# queries](https://codeql.github.com/codeql-query-help/csharp/)
9+
* [Go queries](https://codeql.github.com/codeql-query-help/go/)
10+
* [Java queries](https://codeql.github.com/codeql-query-help/java/)
11+
* [JavaScript queries](https://codeql.github.com/codeql-query-help/javascript/)
12+
* [Python queries](https://codeql.github.com/codeql-query-help/python/)
1213

1314
### Location and file name
1415

@@ -18,57 +19,57 @@ Query help files must have the same base name as the query they describe and mus
1819

1920
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:
2021

21-
```
22+
```xml
2223
<!DOCTYPE qhelp SYSTEM "qhelp.dtd">
2324
<qhelp>
2425
CONTAINS one or more section-level elements
2526
</qhelp>
2627
```
2728

28-
The header and single top-level `<qhelp>` element are both mandatory.
29+
The header and single top-level `<qhelp>` element are both mandatory.
2930

3031
### Section-level elements
3132

3233
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:
3334

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.
3839

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.
4041

4142

4243
## English style
4344

4445
You should write the overview and recommendation elements in simple English that is easy to follow. You should:
4546

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.
5051

5152
## Code examples
5253

5354
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:
5455

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:
6061

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>
6465

65-
<sample src = "example-code-bad.java" />
66+
<sample src = "example-code-bad.java" />
6667

67-
<p>This example shows how to fix the code</p>
68+
<p>This example shows how to fix the code</p>
6869

69-
<sample src = "example-code-fixed.java" />
70-
</example>
71-
```
70+
<sample src = "example-code-fixed.java" />
71+
</example>
72+
```
7273

7374
Note, if any code words are included in the `overview` and `recommendation` sections, they should be formatted with `<code> ... </code>` for emphasis.
7475

@@ -90,7 +91,7 @@ Note, & symbols need to be replaced by \&amp;. The symbol will be displayed corr
9091

9192
### Academic papers
9293

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:
9495

9596
>S. R. Chidamber and C. F. Kemerer, _A metrics suite for object-oriented design_. IEEE Transactions on Software Engineering, 20(6):476-493, 1994.
9697
@@ -109,11 +110,11 @@ For example:
109110

110111
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.
111112

112-
## Query help example
113+
## Query help example
113114

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:
115116

116-
```
117+
```xml
117118
<!DOCTYPE qhelp PUBLIC
118119
"-//Semmle//qhelp//EN"
119120
"qhelp.dtd">

0 commit comments

Comments
 (0)