Knewbury01/cpp misra2023 declarations7#1111
Open
knewbury01 wants to merge 3 commits intogithub:mainfrom
Open
Conversation
…eces previously importing the shared query lib to other queries does not work bc it introduces a select stmt and a problems predicate into the same scope this is now more modular and usable
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a new MISRA C++ 2023 rule query (RULE-11-6-1) for detecting uninitialized local variables, and factors shared initialization/uninitialized-variable logic into common libraries used by queries.
Changes:
- Add new query implementation and tests for RULE-11-6-1 (“UninitializedVariable”).
- Add a new C++ rule package definition for RULE-11-6-1 and wire it into the C++ exclusions/metadata system.
- Refactor uninitialized-variable analysis support code into shared libraries and update the existing shared “read of uninitialized memory” logic to import them.
Show a summary per file
| File | Description |
|---|---|
| rules.csv | Updates rule-to-package mapping (currently points to a likely incorrect package). |
| rule_packages/cpp/Declarations7.json | Adds package metadata for RULE-11-6-1 and the UninitializedVariable query. |
| cpp/misra/src/rules/RULE-11-6-1/UninitializedVariable.ql | Implements the RULE-11-6-1 query using shared initialization analysis logic. |
| cpp/misra/test/rules/RULE-11-6-1/test.cpp | Adds COMPLIANT/NON_COMPLIANT test cases for the new query. |
| cpp/misra/test/rules/RULE-11-6-1/UninitializedVariable.qlref | Links the test harness to the production query. |
| cpp/misra/test/rules/RULE-11-6-1/UninitializedVariable.expected | Adds expected results for the new test cases. |
| cpp/common/src/codingstandards/cpp/rules/readofuninitializedmemory/ReadOfUninitializedMemory.qll | Refactors to import shared initialization context logic instead of defining it inline. |
| cpp/common/src/codingstandards/cpp/exclusions/cpp/RuleMetadata.qll | Wires the new Declarations7 package into query metadata dispatch. |
| cpp/common/src/codingstandards/cpp/exclusions/cpp/Declarations7.qll | Adds autogenerated query metadata mapping for the new package/query. |
| cpp/common/src/codingstandards/cpp/InitializationFunctions.qll | Adds shared library logic for identifying initializer functions (used by initialization context). |
| cpp/common/src/codingstandards/cpp/InitializationContext.qll | Adds shared library logic for modeling initialization context and uninitialized variables. |
Copilot's findings
Comments suppressed due to low confidence (1)
cpp/misra/src/rules/RULE-11-6-1/UninitializedVariable.ql:21
- The alert message is a constant string, which makes it harder to distinguish instances in Code Scanning results. Prefer including at least the variable name (and optionally a
$@link) so the message is specific to the reported element while still being a complete sentence.
from UninitializedVariable v
where not isExcluded(v, Declarations7Package::uninitializedVariableQuery())
- Files reviewed: 10/11 changed files
- Comments generated: 3
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
declarations7
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.