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/query-metadata-style-guide.md
+14-8Lines changed: 14 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -104,6 +104,7 @@ Note, `@id` properties should be consistent for queries that highlight the same
104
104
105
105
* alerts (`@kind problem`)
106
106
* alerts containing path information (`@kind path-problem`)
107
+
* metrics (`@kind metric`)
107
108
108
109
Alert queries (`@kind problem` or `path-problem`) support two further properties. These are added by GitHub staff after the query has been tested, prior to deployment to LGTM. The following information is for reference:
109
110
@@ -123,7 +124,7 @@ The values of `@precision` and `@problem.severity` assigned to a query that is p
123
124
124
125
## Query tags `@tags`
125
126
126
-
The `@tags` property is used to define categories that the query relates to. Each query should belong to one (or more, if necessary) of the following four top-level categories:
127
+
The `@tags` property is used to define categories that the query relates to. Each alert query should belong to one (or more, if necessary) of the following four top-level categories:
127
128
128
129
*`@tags correctness`–for queries that detect incorrect program behavior.
129
130
*`@tags maintainability`–for queries that detect patterns that make it harder for developers to make changes to the code.
@@ -139,6 +140,8 @@ There are also more specific `@tags` that can be added. See, the following pages
Metric queries (`@kind metric`) may have the `summary` tag. If SARIF output is used, the results of these queries can be found at `run[].properties.metricResults`.
144
+
142
145
If necessary, you can also define your own low-level tags to categorize the queries specific to your project or organization. When creating your own tags, you should:
143
146
144
147
* Use all lower-case letters, including for acronyms and proper nouns, with no spaces. All characters apart from * and @ are accepted.
@@ -159,14 +162,9 @@ When you tag a query like this, the associated CWE pages from [MITRE.org](http:/
159
162
160
163
#### Metric/summary `@tags`
161
164
162
-
Queries with `@kind metric` and the `summary` tag represent metrics or other pieces of summary information. If SARIF output is used, the results of these queries can be found at `run[].properties.metricResults`.
165
+
Code Scanning may use tags to identify queries with specific meanings across languages. Currently, there is only one such tag: `lines-of-code`. The sum of the results for queries with this tag that return a single number column ([example for JavaScript](https://github.com/github/codeql/blob/c47d680d65f09a851e41d4edad58ffa7486b5431/java/ql/src/Metrics/Summaries/LinesOfCode.ql)) is interpreted by Code Scanning as the lines of code under the source root present in the database. Each language should have exactly one query of this form.
166
+
163
167
164
-
Code Scanning may use tags to identify queries with specific meanings across languages. Currently, there is only one such tag: `lines-of-code`. The sum of the results for queries with this tag that return a single integer column ([example for JavaScript](https://github.com/github/codeql/blob/c47d680d65f09a851e41d4edad58ffa7486b5431/java/ql/src/Metrics/Summaries/LinesOfCode.ql)) is assumed by Code Scanning to be the lines of code under the source root present in the database. Each language should have exactly one query of this form.
165
-
The `select` clause of a summary metric query must have one of the following result patterns:
166
-
- Just a `number`
167
-
- This indicates a metric without a specific location in the codebase, for example the total lines of code in a codebase.
168
-
- A code `entity` followed by a `number`
169
-
- This indicates a metric with a specific location in the codebase, for example the lines of code within a file. The `entity` here must have a valid location in the source code.
170
168
## QL area
171
169
172
170
### Alert messages
@@ -190,3 +188,11 @@ For examples of select clauses and alert messages, see the query source files at
For further information on query writing, see [CodeQL queries](https://help.semmle.com/QL/learn-ql/ql/writing-queries/writing-queries.html). For more information on learning CodeQL, see [Learning CodeQL](https://help.semmle.com/QL/learn-ql/index.html).
191
+
192
+
## Metric results
193
+
194
+
The `select` clause of a summary metric query must have one of the following result patterns:
195
+
- Just a `number`
196
+
- This indicates a metric without a specific location in the codebase, for example the total lines of code in a codebase.
197
+
- A code `entity` followed by a `number`
198
+
- This indicates a metric with a specific location in the codebase, for example the lines of code within a file. The `entity` here must have a valid location in the source code.
0 commit comments