Add "Baseline" query suites for C/C++.#966
Open
MichaelRFairhurst wants to merge 12 commits intomainfrom
Open
Conversation
These are queries from MISRA, AUTOSAR, and CERT, that have been hand picked based on a few properties: - review of violation count for each rule on real projects - review of accuracy of each rule - subjective review of broad applicability across most projects - subjective review of severity of each rule The baseline rules have been divided into two categories, "style," and "safety." The choice of which is subjective, but as a general rule: - Rules that tend to report only erroneous cases are typically "safety." - Rules that tend to report patterns that obscure erroneous behavior are typically "style." - If alerts can be mitigated by simple changes, it's more likely "style." - If it is challenging for a human to spot the rule violation, it's more likely "safety." - If the rule is designed to enforce some kind of "good habits," not just fix an isolated it's more likely "style." - If the rule feels "opinionated" in some sense, it's more likely "style." - If it is difficult to decide whether a finding should be fixed or deviated, it is more likely "safety." - Unsurprisingly, if the rule is purely syntactic or related to naming, it's more likely "style." Some rules are in both suites -- for instance, rules that ban the use of 'goto' are conceivably both "style" and "safety." While goto is not erroneous in itself, and gotos are easy to spot during human review, it is typically not a simple task to refactor code to remove gotos, and it is difficult to decide when a goto serves a legitimate purpose and the rule should be deviated. In general, the 'style' suites have more violations which are easier to fix, and the 'safety' suites have fewer violation that are harder to fix but warrant more attention to address. Project authors can therefore enable both with the 'default' suite, or pick between the two kinds suitable for their project and goals.
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR introduces baseline query suites for C/C++ by categorizing selected queries from MISRA, AUTOSAR, and CERT standards into "style" and "safety" categories. The baseline queries are hand-picked based on violation frequency, accuracy, broad applicability, and severity analysis on real projects.
- Adds
coding-standards/baseline/styleandcoding-standards/baseline/safetytags to 100+ existing query files - Creates new baseline query suite packages for both C and C++
- Provides three suite options: default (both style and safety), style-only, and safety-only
Reviewed Changes
Copilot reviewed 300 out of 417 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| cpp/autosar/src/rules/**/*.ql | Added baseline tags (style/safety) to AUTOSAR C++ rules based on categorization criteria |
| c/misra/src/rules/**/*.ql | Added baseline tags (style/safety) to MISRA C rules |
| c/cert/src/rules/**/*.ql | Added baseline tags (style/safety) to CERT C rules |
| c/baseline_suites/* | Created new C baseline query suite package with suite definitions |
| cpp/baseline_suites/* | Created new C++ baseline query suite package (referenced but not shown in diff) |
| .codeqlmanifest.json | Registered new baseline suite packages |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…-baseline-query-suites
Collaborator
Author
|
@jeongsoolee09 @data-douser @knewbury01 this is now passing CI/CD and ready for review. |
…-baseline-query-suites
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
These are queries from MISRA, AUTOSAR, and CERT, that have been hand picked based on a few properties:
The baseline rules have been divided into two categories, "style," and "safety." The choice of which is subjective, but as a general rule:
Some rules are in both suites -- for instance, rules that ban the use of 'goto' are conceivably both "style" and "safety." While goto is not erroneous in itself, and gotos are easy to spot during human review, it is typically not a simple task to refactor code to remove gotos, and it is difficult to decide when a goto serves a legitimate purpose and the rule should be deviated.
In general, the 'style' suites have more violations which are easier to fix, and the 'safety' suites have fewer violation that are harder to fix but warrant more attention to address. Project authors can therefore enable both with the 'default' suite, or pick between the two kinds suitable for their project and goals.
Change request type
.ql,.qll,.qlsor 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.