Skip to content

Commit 36fe86f

Browse files
author
james
committed
address felicity's comments
1 parent 59542fc commit 36fe86f

File tree

1 file changed

+24
-16
lines changed

1 file changed

+24
-16
lines changed

docs/query-metadata-style-guide.md

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Query file metadata and alert message style-guide
1+
# Query file metadata and alert message style guide
22

33

44
## Introduction
@@ -11,12 +11,13 @@ Query files have the extension `.ql`. Each file has two distinct areas:
1111

1212
* Metadata area–displayed at the top of the file, contains the metadata that defines how results for the query are interpreted and gives a brief description of the purpose of the query.
1313
* Query definition–defined using QL. The query includes a select statement, which defines the content and format of the results. For further information about writing QL, see the following topics:
14-
* [Learning QL](https://help.semmle.com/wiki/display/QL/Learning+QL)
14+
* [Learning QL](https://help.semmle.com/QL/learn-ql/index.html)
1515
* [QL language handbook](https://help.semmle.com/QL/ql-handbook/index.html)
16-
* [QL language specification](https://help.semmle.com/QL/QLLanguageSpecification.html)
17-
* [QL style Guide](https://github.com/Semmle/ql/blob/master/docs/ql-style-guide.md)
16+
* [QL language specification](https://help.semmle.com/QL/ql-spec/language.html)
17+
* [QL style guide](https://github.com/Semmle/ql/blob/master/docs/ql-style-guide.md)
1818

19-
For examples of query files for the languages supported by Semmle, see the following pages:
19+
20+
For examples of query files for the languages supported by Semmle, visit the following links:
2021

2122
* [C/C++ queries](https://wiki.semmle.com/pages/viewpage.action?pageId=19334052)
2223
* [C# queries](https://wiki.semmle.com/display/CSHARP/C%23+queries)
@@ -27,7 +28,7 @@ For examples of query files for the languages supported by Semmle, see the follo
2728

2829
## Metadata area
2930

30-
Query file metadata contains important information which defines the name and purpose of the query. The metadata is included as the content of a valid QLDoc comment, on lines with leading whitespace followed by `*`, between an initial `/**` and a trailing `*/`. For example:
31+
Query file metadata contains important information which defines the identifier and purpose of the query. The metadata is included as the content of a valid [QLDoc](https://help.semmle.com/QL/ql-spec/qldoc.html) comment, on lines with leading whitespace followed by `*`, between an initial `/**` and a trailing `*/`. For example:
3132

3233
```
3334
/**
@@ -43,11 +44,11 @@ Query file metadata contains important information which defines the name and pu
4344
*/
4445
```
4546

46-
In order to help others use your query, and to ensure that the query works correctly on LGTM.com, you should include all of the required information outlined below in the metadata, and as much of the optional information as possible. For further information on query metadata see [Query file requirements](https://help.semmle.com/wiki/display/SD/Query+file+requirements).
47+
In order to help others use your query, and to ensure that the query works correctly on LGTM, you should include all of the required information outlined below in the metadata, and as much of the optional information as possible. For further information on query metadata see [Query file requirements](https://help.semmle.com/wiki/display/SD/Query+file+requirements).
4748

4849
### Query name `@name`
4950

50-
You must specify an `@name` property for your query. This property defines the display name for the query. Query names should use sentence capitalization, but not include a full stop. Filter queries should specify the results that are excluded when you run the query. See the following examples for more detail:
51+
You must specify an `@name` property for your query. This property defines the display name for the query. Query names should use sentence capitalization, but not include a full stop. For example:
5152

5253
* `@name Access to variable in enclosing class`
5354
* `@name Array argument size mismatch`
@@ -103,7 +104,7 @@ Note, `@id` properties should be consistent for queries that highlight the same
103104
* alerts (`@kind problem`)
104105
* alerts containing path information (`@kind path-problem`)
105106

106-
These `@kind` properties support two further mandatory properties which are added by Semmle after the query has been tested, prior to deployment to LGTM. The following information is for reference:
107+
These `@kind` properties support two further properties which are added by Semmle after the query has been tested, prior to deployment to LGTM. The following information is for reference:
107108

108109

109110

@@ -128,7 +129,7 @@ The `@tags` property is used to define categories that the query relates to. Eac
128129
* `@tags readability`–for queries that detect confusing patterns that make it harder for developers to read the code.
129130
* `@tags security`–for queries that detect security weaknesses. See below for further information.
130131

131-
There are also more specific `@tags` that can be specified. See, the following pages for more information on the low-level tags:
132+
There are also more specific `@tags` that can be specified. See, the the following pages for examples of the low-level tags:
132133

133134
* [C/C++ queries](https://wiki.semmle.com/pages/viewpage.action?pageId=19334052)
134135
* [C# queries](https://wiki.semmle.com/display/CSHARP/C%23+queries)
@@ -153,21 +154,28 @@ If your query is a security query, use one or more `@tags` to associate it with
153154
||`external/cwe/cwe-036` |
154155
||`external/cwe/cwe-073` |
155156

156-
When you tag a query like this, the associated CWE pages from [MITRE.org](http://cwe.mitre.org/index.html) will automatically appear in the reference section of its associated qhelp file. For more information on qhelp files, see [Query help style guide](https://docs.google.com/document/d/14E-bne3sO3boo0jbmD68XMdTZknN5dXSTXBGQeAfj6A/edit#).
157+
When you tag a query like this, the associated CWE pages from [MITRE.org](http://cwe.mitre.org/index.html) will automatically appear in the reference section of its associated qhelp file.
157158

158159
## QL area
159160

160161
### Alert messages
161162

162-
You must define a message in the select clause of an alert query to display with your results. Alert messages are strings that concisely describe the problem that the alert is highlighting and, if possible, also provide some context. For consistency, alert messages should adhere to the following guidelines:
163+
The select clause of each alert query defines the alert message that is displayed for each result found by the query. Alert messages are strings that concisely describe the problem that the alert is highlighting and, if possible, also provide some context. For consistency, alert messages should adhere to the following guidelines:
163164

164165
* Each message should be a complete, standalone sentence. That is, it should be capitalized and have proper punctuation, including a full stop.
165166
* The message should factually describe the problem that is being highlighted–it should not contain recommendations about how to fix the problem or value judgements.
166167
* Program element references should be in 'single quotes' to distinguish them from ordinary words. Quotes are not needed around substitutions ($@).
167168
* Avoid constant alert message strings and include some context, if possible. For example, `The class 'Foo' is duplicated as 'Bar'.` is preferable to `This class is duplicated here.`
168-
* Where you reference another program element, link to it if possible using a substitution (`$@`). Links should be used inline in the sentence, rather than as parenthesised lists or appositions.
169-
* When a message contains multiple links, construct a sentence that has the most variable link (that is, the link with most targets) last.
169+
* Where you reference another program element, link to it if possible using a substitution (`$@`). Links should be used inline in the sentence, rather than as parenthesised lists or appositions.
170+
* When a message contains multiple links, construct a sentence that has the most variable link (that is, the link with most targets) last. For further information, see [Defining select statements](https://help.semmle.com/QL/learn-ql/ql/writing-queries/select-statement.html)
171+
172+
See the following pages for examples of alert messages:
170173

171-
See the query homepages for examples of alert messages.
174+
* [C/C++ queries](https://wiki.semmle.com/pages/viewpage.action?pageId=19334052)
175+
* [C# queries](https://wiki.semmle.com/display/CSHARP/C%23+queries)
176+
* [COBOL queries](https://wiki.semmle.com/display/COBOL/COBOL+queries)
177+
* [Java queries](https://wiki.semmle.com/display/JAVA/Java+queries)
178+
* [JavaScript queries](https://wiki.semmle.com/display/JS/JavaScript+queries)
179+
* [Python queries](https://wiki.semmle.com/display/PYTHON/Python+queries)
172180

173-
For further information on query writing, see [Writing QL queries](https://lgtm.com/help/ql/writing-queries/writing-queries). For more information on learning QL, see [Learning QL](https://lgtm.com/help/lgtm/ql/learning-ql).
181+
For further information on query writing, see [Writing QL queries](https://help.semmle.com/QL/learn-ql/ql/writing-queries/writing-queries.html). For more information on learning QL, see [Learning QL](https://help.semmle.com/QL/learn-ql/index.html).

0 commit comments

Comments
 (0)