-
Notifications
You must be signed in to change notification settings - Fork 61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for deviations on next line and multiple lines #807
Conversation
lgtm-style suppressions are no longer supported by CodeQL and Code Scanning.
This new library supports deviating on the next line, or on ranges, in addition to deviating on the current line.
This ties in the code-identifier deviation support to the deviations and exclusions libraries.
This commit adds support for C/C++ attributes to specify deviations with code identifiers in the code. Attributes are inherited from parents, and support multiple code identifiers in a single definition.
Attributes are inherited from their parent. Includes support for features which are not currently enabled, due to lack of support in CodeQL itself.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fun PR to read through, very cool to see the stack as a solution for implementing pairings in an immutable context like CodeQL! Some thoughts on it since its a cool weedy coding task!
cpp/common/src/codingstandards/cpp/deviations/CodeIdentifierDeviation.qll
Outdated
Show resolved
Hide resolved
cpp/common/src/codingstandards/cpp/deviations/CodeIdentifierDeviation.qll
Outdated
Show resolved
Hide resolved
cpp/common/src/codingstandards/cpp/deviations/CodeIdentifierDeviation.qll
Show resolved
Hide resolved
cpp/common/src/codingstandards/cpp/deviations/CodeIdentifierDeviation.qll
Outdated
Show resolved
Hide resolved
cpp/common/src/codingstandards/cpp/deviations/InvalidDeviationCodeIdentifier.ql
Show resolved
Hide resolved
cpp/common/src/codingstandards/cpp/deviations/InvalidDeviationCodeIdentifier.md
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, LGTM! Just one question left.
cpp/common/src/codingstandards/cpp/deviations/CodeIdentifierDeviation.qll
Outdated
Show resolved
Hide resolved
cpp/common/src/codingstandards/cpp/deviations/CodeIdentifierDeviation.qll
Outdated
Show resolved
Hide resolved
cpp/common/src/codingstandards/cpp/deviations/CodeIdentifierDeviation.qll
Outdated
Show resolved
Hide resolved
Deviation code identifier markers can have multiple records.
/test-performance |
🏁 Beep Boop! Performance testing for this PR has been initiated. Please check back later for results. Note that the query package generation step must complete before testing will start so it might be a minute. |
🏁 Beep Boop! Performance testing complete! See below for performance of the last 3 runs vs your PR. Times are based on predicate performance. You can find full graphs and stats in the PR that was created for this test in the release engineering repo.
🏁 Below are the slowest predicates for the last 2 releases vs this PR.
|
While going through the first table, I think that The salient result I noticed in 807 is in the second table:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
@fjatWbyT yes, good catch. That was introduced past the last release (by me!) and was fixed. Overall, esp. with that fixed, everything here looks great to me. |
Description
This PR proposes an extension of our deviations mechanism to support easier suppression of results at scale - including applying deviations to a block of code, to code on the next line and to code in macros.
We introduce a C/C++ attribute format -
[[codeql::<standard>_deviation(<code-identifier>)]]
- which applies the deviation distinguished by the<code-identifier>
to the program element, and those nested within it. This attribute can be applied to:For example,
[[codeql::autosar_deviation("a0-4-2")]]
would apply the deviation specified using the code identifiera0-4-2
, related to theautosar
Coding Standard.Custom attributes are not universally supported - for example, they were only introduced in C23 - so we also provide an attribute-like syntax to be used in comment markers:
codeql::<standard>_deviation(<code-identifier>)
- the deviation applies to results on the current line (duplication of existing non-annotated support, included for consistency).codeql::<standard>_deviation_next_line(<code-identifier>)
- this deviation applies to results on the next line.codeql::<standard>_deviation_begin(<code-identifier>)
- marks the beginning of a range of lines where the deviation applies.codeql::<standard>_deviation_end(<code-identifier>)
- marks the end of a range of lines where the deviation applies.This would address #326.
Change request type
.ql
,.qll
,.qls
or unit tests)Rules with added or modified queries
Release change checklist
A change note (development_handbook.md#change-notes) is required for any pull request which modifies:
If you are only adding new rule queries, a change note is not required.
Author: Is a change note required?
🚨🚨🚨
Reviewer: Confirm that format of shared queries (not the .qll file, the
.ql file that imports it) is valid by running them within VS Code.
Reviewer: Confirm that either a change note is not required or the change note is required and has been added.
Query development review checklist
For PRs that add new queries or modify existing queries, the following checklist should be completed by both the author and reviewer:
Author
As a rule of thumb, predicates specific to the query should take no more than 1 minute, and for simple queries be under 10 seconds. If this is not the case, this should be highlighted and agreed in the code review process.
Reviewer
As a rule of thumb, predicates specific to the query should take no more than 1 minute, and for simple queries be under 10 seconds. If this is not the case, this should be highlighted and agreed in the code review process.