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
+19-1Lines changed: 19 additions & 1 deletion
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.
@@ -157,6 +160,11 @@ If your query is a security query, use one or more `@tags` to associate it with
157
160
158
161
When you tag a query like this, the associated CWE pages from [MITRE.org](https://cwe.mitre.org/index.html) will automatically appear in the reference section of its associated qhelp file.
159
162
163
+
#### Metric/summary `@tags`
164
+
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
+
167
+
160
168
## QL area
161
169
162
170
### Alert messages
@@ -180,3 +188,13 @@ For examples of select clauses and alert messages, see the query source files at
For further information on query writing, see [CodeQL queries](https://codeql.github.com/docs/writing-codeql-queries/codeql-queries/). For more information on learning CodeQL, see [CodeQL documentation](https://codeql.github.com/docs/).
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