Skip to content

Commit fc38960

Browse files
committed
Split up metric information across the doc
1 parent 2c14c98 commit fc38960

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

docs/query-metadata-style-guide.md

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ Note, `@id` properties should be consistent for queries that highlight the same
104104

105105
* alerts (`@kind problem`)
106106
* alerts containing path information (`@kind path-problem`)
107+
* metrics (`@kind metric`)
107108

108109
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:
109110

@@ -123,7 +124,7 @@ The values of `@precision` and `@problem.severity` assigned to a query that is p
123124

124125
## Query tags `@tags`
125126

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

128129
* `@tags correctness`–for queries that detect incorrect program behavior.
129130
* `@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
139140
* [JavaScript queries](https://help.semmle.com/wiki/display/JS/)
140141
* [Python queries](https://help.semmle.com/wiki/display/PYTHON/)
141142

143+
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+
142145
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:
143146

144147
* 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:/
159162

160163
#### Metric/summary `@tags`
161164

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+
163167

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.
170168
## QL area
171169

172170
### Alert messages
@@ -190,3 +188,11 @@ For examples of select clauses and alert messages, see the query source files at
190188
* [Python queries](https://help.semmle.com/wiki/display/PYTHON/)
191189

192190
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

Comments
 (0)