From 2629f55d95646c630ce61e8e3497af7844fea838 Mon Sep 17 00:00:00 2001 From: Max Schaefer Date: Fri, 28 Feb 2020 14:43:00 +0000 Subject: [PATCH 1/3] Add guidelines for experimental CodeQL queries and libraries. --- CONTRIBUTING.md | 6 ++++++ docs/experimental.md | 37 ++++++++++++++++++++++++++++++++++ ql/src/experimental/README.md | 1 + ql/test/experimental/README.md | 1 + 4 files changed, 45 insertions(+) create mode 100644 docs/experimental.md create mode 100644 ql/src/experimental/README.md create mode 100644 ql/test/experimental/README.md diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 434db678197..28af7813134 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -36,6 +36,12 @@ Follow the steps below to help other users understand what your query does, and Query help files explain the purpose of your query to other users. Write your query help in a `.qhelp` file and save it in the same directory as your new query. For more information on writing query help, see the [Query help style guide](https://github.com/Semmle/ql/blob/master/docs/query-help-style-guide.md). +6. **Maintain backwards compatibility** + +The standard CodeQL libraries must evolve in a backwards compatible manner. If any backwards incompatible changes need to be made, the existing API must first be marked as deprecated. This is done by adding a `deprecated` annotation along with a QLDoc reference to the replacement API. Only after at least one full release cycle has elapsed may the old API be removed. + +In addition to contributions to our standard queries and libraries, we also welcome contributions of a more experimental nature, which do not need to fulfill all the requirements listed above. See the guidelines for [experimental queries and libraries](docs/experimental.md) for details. + ## Resources - [How to Contribute to Open Source](https://opensource.guide/how-to-contribute/) diff --git a/docs/experimental.md b/docs/experimental.md new file mode 100644 index 00000000000..02a33788b09 --- /dev/null +++ b/docs/experimental.md @@ -0,0 +1,37 @@ +# Experimental CodeQL queries and libraries + +In addition to our standard CodeQL queries and libraries, this repository may also contain queries and libraries of a more experimental nature. Experimental queries and libraries can be improved incrementally and may eventually reach a sufficient maturity to be included in our standard libraries and queries. + +Experimental queries and libraries may not be actively maintained as the standard libraries evolve. They may also be changed in backwards-incompatible ways or may be removed entirely in the future without deprecation warnings. + +## Requirements + +1. **Directory structure** + + - Experimental queries and libraries are stored in the `ql/src/experimental` subdirectory, and any corresponding tests in `ql/test/experimental`. + - The structure of an `experimental` subdirectory mirrors the structure of standard queries and libraries (or tests) in the parent directory. + +2. **Query metadata** + + - The query `@id` must not clash with any other queries in the repository. + - The query must have a `@name` and `@description` to explain its purpose. + - The query must have a `@kind` and `@problem.severity` as required by CodeQL tools. + + For details, see the [guide on query metadata](https://github.com/Semmle/ql/blob/master/docs/query-metadata-style-guide.md). + +3. **Formatting** + + - The queries and libraries must be [autoformatted](https://help.semmle.com/codeql/codeql-for-vscode/reference/editor.html#autoformatting). + +4. **Compilation** + + - Compilation of the query and any associated libraries and tests must be resilient to future development of the standard libraries. This means that the functionality cannot use internal APIs, cannot depend on the output of `getAQlClass`, and cannot make use of regexp matching on `toString`. + - The query and any associated libraries and tests must not cause any compiler warnings to be emitted (such as use of deprecated functionality or missing `override` annotations). + +5. **Results** + + - The query must have at least one true positive result on some revision of a real project. + +## Non-requirements + +Other criteria typically required for our standard queries and libraries are not required for experimental queries and libraries. In particular, fully disciplined query [metadata](https://git.semmle.com/Semmle/ql/blob/master/docs/query-metadata-style-guide.md), query [help](https://git.semmle.com/Semmle/ql/blob/master/docs/query-help-style-guide.md), tests, a low false positive rate and performance tuning are not required (but nonetheless recommended). diff --git a/ql/src/experimental/README.md b/ql/src/experimental/README.md new file mode 100644 index 00000000000..05708ba43e1 --- /dev/null +++ b/ql/src/experimental/README.md @@ -0,0 +1 @@ +This directory contains [experimental](../../../docs/experimental.md) CodeQL queries and libraries. diff --git a/ql/test/experimental/README.md b/ql/test/experimental/README.md new file mode 100644 index 00000000000..05708ba43e1 --- /dev/null +++ b/ql/test/experimental/README.md @@ -0,0 +1 @@ +This directory contains [experimental](../../../docs/experimental.md) CodeQL queries and libraries. From cef017071f7fb3350b2272a9419f905332f7793c Mon Sep 17 00:00:00 2001 From: Max Schaefer Date: Mon, 2 Mar 2020 09:23:06 +0000 Subject: [PATCH 2/3] Move guidelines into `ql` folder. --- CONTRIBUTING.md | 2 +- {docs => ql/docs}/experimental.md | 0 ql/src/experimental/README.md | 2 +- ql/test/experimental/README.md | 2 +- 4 files changed, 3 insertions(+), 3 deletions(-) rename {docs => ql/docs}/experimental.md (100%) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 28af7813134..39a30db4ecb 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -40,7 +40,7 @@ Follow the steps below to help other users understand what your query does, and The standard CodeQL libraries must evolve in a backwards compatible manner. If any backwards incompatible changes need to be made, the existing API must first be marked as deprecated. This is done by adding a `deprecated` annotation along with a QLDoc reference to the replacement API. Only after at least one full release cycle has elapsed may the old API be removed. -In addition to contributions to our standard queries and libraries, we also welcome contributions of a more experimental nature, which do not need to fulfill all the requirements listed above. See the guidelines for [experimental queries and libraries](docs/experimental.md) for details. +In addition to contributions to our standard queries and libraries, we also welcome contributions of a more experimental nature, which do not need to fulfill all the requirements listed above. See the guidelines for [experimental queries and libraries](ql/docs/experimental.md) for details. ## Resources diff --git a/docs/experimental.md b/ql/docs/experimental.md similarity index 100% rename from docs/experimental.md rename to ql/docs/experimental.md diff --git a/ql/src/experimental/README.md b/ql/src/experimental/README.md index 05708ba43e1..ed83d8d4ab0 100644 --- a/ql/src/experimental/README.md +++ b/ql/src/experimental/README.md @@ -1 +1 @@ -This directory contains [experimental](../../../docs/experimental.md) CodeQL queries and libraries. +This directory contains [experimental](../../docs/experimental.md) CodeQL queries and libraries. diff --git a/ql/test/experimental/README.md b/ql/test/experimental/README.md index 05708ba43e1..ed83d8d4ab0 100644 --- a/ql/test/experimental/README.md +++ b/ql/test/experimental/README.md @@ -1 +1 @@ -This directory contains [experimental](../../../docs/experimental.md) CodeQL queries and libraries. +This directory contains [experimental](../../docs/experimental.md) CodeQL queries and libraries. From 56e07356fc09fd1e4437d367fc01c9b49181bdcd Mon Sep 17 00:00:00 2001 From: Max Schaefer <54907921+max-schaefer@users.noreply.github.com> Date: Mon, 2 Mar 2020 10:20:07 +0000 Subject: [PATCH 3/3] Update ql/test/experimental/README.md Co-Authored-By: Felicity Chapman --- ql/test/experimental/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ql/test/experimental/README.md b/ql/test/experimental/README.md index ed83d8d4ab0..0c9c0305c7b 100644 --- a/ql/test/experimental/README.md +++ b/ql/test/experimental/README.md @@ -1 +1 @@ -This directory contains [experimental](../../docs/experimental.md) CodeQL queries and libraries. +This directory contains tests for [experimental](../../docs/experimental.md) CodeQL queries and libraries.