Skip to content

Commit 44b9de0

Browse files
authored
Merge pull request github#6011 from github/docs-4433-diagnostic-info
Make minimal changes to CodeQL docs for new diagnostic data
2 parents d254524 + aad738b commit 44b9de0

File tree

3 files changed

+19
-5
lines changed

3 files changed

+19
-5
lines changed

docs/codeql/codeql-cli/analyzing-databases-with-the-codeql-cli.rst

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,12 @@ Before starting an analysis you must:
2424
Running ``codeql database analyze``
2525
------------------------------------
2626

27-
When you run ``database analyze``, it does two things:
27+
When you run ``database analyze``, it:
2828

2929
#. Executes one or more query files, by running them over a CodeQL database.
3030
#. Interprets the results, based on certain query metadata, so that alerts can be
3131
displayed in the correct location in the source code.
32+
#. Reports the results of any diagnostic and summary queries to standard output.
3233

3334
You can analyze a database by running the following command::
3435

@@ -142,6 +143,13 @@ These are stored alongside the code scanning suites with names of the form: ``<l
142143
For information about creating custom query suites, see ":doc:`Creating
143144
CodeQL query suites <creating-codeql-query-suites>`."
144145

146+
Diagnostic and summary information
147+
..................................
148+
149+
When you create a CodeQL database, the extractor stores diagnostic data in the database. The code scanning query suites include additional queries to report on this diagnostic data and calculate summary metrics. When the ``database analyze`` command completes, the CLI generates the results file and reports any diagnostic and summary data to standard output. If you choose to generate SARIF output, the additional data is also included in the SARIF file.
150+
151+
If the analysis found fewer results for standard queries than you expected, review the results of the diagnostic and summary queries to check whether the CodeQL database is likely to be a good representation of the codebase that you want to analyze.
152+
145153
Running all queries in a directory
146154
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
147155

docs/codeql/codeql-cli/using-custom-queries-with-the-codeql-cli.rst

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,10 @@ following two properties to ensure that the results are interpreted correctly:
3333

3434
- Query identifier (``@id``): a sequence of words composed of lowercase letters or
3535
digits, delimited by ``/`` or ``-``, identifying and classifying the query.
36-
- Query type (``@kind``): identifies the query is an alert (``@kind problem``)
37-
or a path (``@kind path-problem``).
36+
- Query type (``@kind``): identifies the query as a simple alert (``@kind problem``),
37+
an alert documented by a sequence of code locations (``@kind path-problem``),
38+
for extractor troubleshooting (``@kind diagnostic``), or a summary metric
39+
(``@kind metric`` and ``@tags summary``).
3840

3941
For more information about these metadata properties, see ":ref:`Metadata for CodeQL queries
4042
<metadata-for-codeql-queries>`" and the `Query metadata style guide

docs/codeql/writing-codeql-queries/about-codeql-queries.rst

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,10 @@ Query metadata is used to identify your custom queries when they are added to th
5757

5858
Queries that are contributed to the open source repository, added to a query pack in LGTM, or used to analyze a database with the :ref:`CodeQL CLI <codeql-cli>` must have a query type (``@kind``) specified. The ``@kind`` property indicates how to interpret and display the results of the query analysis:
5959

60-
- Alert query metadata must contain ``@kind problem``.
61-
- Path query metadata must contain ``@kind path-problem``.
60+
- Alert query metadata must contain ``@kind problem`` to identify the results as a simple alert.
61+
- Path query metadata must contain ``@kind path-problem`` to identify the results as an alert documented by a sequence of code locations.
62+
- Diagnostic query metadata must contain ``@kind diagnostic`` to identify the results as troubleshooting data about the extraction process.
63+
- Summary query metadata must contain ``@kind metric`` and ``@tags summary`` to identify the results as summary metrics for the CodeQL database.
6264

6365
When you define the ``@kind`` property of a custom query you must also ensure that the rest of your query has the correct structure in order to be valid, as described below.
6466

@@ -114,6 +116,8 @@ You can modify the alert message defined in the final column of the ``select`` s
114116

115117
Select clauses for path queries (``@kind path-problem``) are crafted to display both an alert and the source and sink of an associated path graph. For more information, see ":doc:`Creating path queries <creating-path-queries>`."
116118

119+
Select clauses for diagnostic queries (``@kind diagnostic``) and summary metric queries (``@kind metric`` and ``@tags summary``) have different requirements. For examples, see the `diagnostic queries <https://github.com/github/codeql/search?q=%22%40kind+diagnostic%22>`__ and the `summary metric queries <https://github.com/github/codeql/search?q=%22%40kind+metric%22+%22%40tags+summary%22>`__ in the CodeQL repository.
120+
117121
Viewing the standard CodeQL queries
118122
***********************************
119123

0 commit comments

Comments
 (0)