Skip to content

Commit de5d3b6

Browse files
authored
Update query-metadata-style-guide.md
1 parent 6c28be9 commit de5d3b6

File tree

1 file changed

+23
-17
lines changed

1 file changed

+23
-17
lines changed

docs/query-metadata-style-guide.md

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,9 @@ Alert queries (`@kind problem` or `path-problem`) support two further properties
121121

122122
## Query tags `@tags`
123123

124-
The `@tags` property is used to define categories that the query relates to. As we prepare for the release of a dedicated code quality product, we will use tagging to prepare a stronger delineation between queries that are part of our existing "code security" product offering and those that are better suited as part of a "quality" product offering. Each alert query should belong to one of the following two top-level categories, with additional sub-categories:
124+
The `@tags` property is used to define the high level category of problem that the query relates to. Each alert query should belong to one of the following two top-level categories, with additional sub-categories:
125125

126-
#### High level category `@tags`
126+
### High level category `@tags`
127127
* `@tags security`–for queries that detect security weaknesses. See below for further information.
128128
* `@tags quality`–for queries that detect code quality issues. See below for further information.
129129

@@ -149,18 +149,19 @@ When you tag a query like this, the associated CWE pages from [MITRE.org](https:
149149

150150
Software quality doesn't have as universally-agreed categorization method as security issues like CWE, so we will do our own categorization instead of using tags like CWE.
151151

152-
We'll have two "top-level" categories of quality queries, with sub-categories beneath:
152+
We'll use two "top-level" categories of quality queries, with sub-categories beneath:
153153

154154
* `@tags maintainability`–for queries that detect patterns that make it harder for developers to make changes to the code.
155155
* `@tags readability`–for queries that detect confusing patterns that make it harder for developers to read the code.
156-
*
157-
156+
* `@tags unused-code`-for queries that detect functions that are never used and other instances of unused code
157+
* `@tags complexity`-for queries that detect patterns in the code that lead to unnecesary complexity such as unclear control flow, or high cyclomatic complexity
158+
158159

159160
* `@tags reliability`–for queries that detect issues that affect whether the code will perform as expected during execution.
160-
* `@tags correctness`–for queries that detect incorrect program behavior.
161-
162-
163-
161+
* `@tags correctness`–for queries that detect incorrect program behavior or couse result in unintended outcomes.
162+
* `@tags performance`-for queries that detect code that could impact performance through inefficient algorithms, unnecessary computation, etc
163+
* `@tags concurrency`-for queries that detect concurrency related issues such as race conditions, deadlocks, thread safety, etc
164+
* `@tags error-handling`-for queries that detect issues related to unsafe error handling such as uncaught exceptions, etc
164165

165166

166167
There are also more specific `@tags` that can be added. See, the following pages for examples of the low-level tags:
@@ -172,22 +173,27 @@ There are also more specific `@tags` that can be added. See, the following pages
172173
* [JavaScript queries](https://codeql.github.com/codeql-query-help/javascript/)
173174
* [Python queries](https://codeql.github.com/codeql-query-help/python/)
174175

175-
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`.
176176

177-
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:
178-
179-
* Use all lower-case letters, including for acronyms and proper nouns, with no spaces. All characters apart from * and @ are accepted.
180-
* Use a forward slash / to indicate a hierarchical relationship between tags if necessary. For example, a query with tag `foo/bar` is also interpreted as also having tag `foo`, but not `bar`.
181-
* Use a single-word `@tags` name. Multiple words, separated with hyphens, can be used for clarity if necessary.
177+
### Severities
182178

179+
Maintainers are expected to add a `@security-severity` tag to security relevant queries that will be run on Code Scanning. There is a documented internal process for generating these `@security-severity` values.
183180

181+
TODO: should we have a severity value for quality queries?
184182

185-
#### Metric/summary `@tags`
183+
### Metric/summary `@tags`
186184

187185
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.
188186

187+
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`.
189188

190-
Maintainers are expected to add a `@security-severity` tag to security relevant queries that will be run on Code Scanning. There is a documented internal process for generating these `@security-severity` values.
189+
190+
### Customizing tags
191+
192+
If necessary, you can also define your own low-level tags to categorize the queries specific to your project or organization, but if possible, please try to follow the above standards (or propose changes to this style guide). When creating your own tags, you should:
193+
194+
* Use all lower-case letters, including for acronyms and proper nouns, with no spaces. All characters apart from * and @ are accepted.
195+
* Use a forward slash / to indicate a hierarchical relationship between tags if necessary. For example, a query with tag `foo/bar` is also interpreted as also having tag `foo`, but not `bar`.
196+
* Use a single-word `@tags` name. Multiple words, separated with hyphens, can be used for clarity if necessary.
191197

192198
## QL area
193199

0 commit comments

Comments
 (0)