Skip to content

Knewbury01/cpp misra2023 declarations7#1111

Open
knewbury01 wants to merge 3 commits intogithub:mainfrom
knewbury01:knewbury01/cpp-misra2023-declarations7
Open

Knewbury01/cpp misra2023 declarations7#1111
knewbury01 wants to merge 3 commits intogithub:mainfrom
knewbury01:knewbury01/cpp-misra2023-declarations7

Conversation

@knewbury01
Copy link
Copy Markdown
Collaborator

@knewbury01 knewbury01 commented Apr 17, 2026

Description

declarations7

Change request type

  • Release or process automation (GitHub workflows, internal scripts)
  • Internal documentation
  • External documentation
  • Query files (.ql, .qll, .qls or unit tests)
  • External scripts (analysis report or other code shipped as part of a release)

Rules with added or modified queries

  • No rules added
  • Queries have been added for the following rules:
    • RULE-11-6-1
  • Queries have been modified for the following rules:
    • rule number here

Release change checklist

A change note (development_handbook.md#change-notes) is required for any pull request which modifies:

  • The structure or layout of the release artifacts.
  • The evaluation performance (memory, execution time) of an existing query.
  • The results of an existing query in any circumstance.

If you are only adding new rule queries, a change note is not required.

Author: Is a change note required?

  • Yes
  • No

🚨🚨🚨
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.

  • Confirmed

Reviewer: Confirm that either a change note is not required or the change note is required and has been added.

  • Confirmed

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

  • Have all the relevant rule package description files been checked in?
  • Have you verified that the metadata properties of each new query is set appropriately?
  • Do all the unit tests contain both "COMPLIANT" and "NON_COMPLIANT" cases?
  • Are the alert messages properly formatted and consistent with the style guide?
  • Have you run the queries on OpenPilot and verified that the performance and results are acceptable?
    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.
  • Does the query have an appropriate level of in-query comments/documentation?
  • Have you considered/identified possible edge cases?
  • Does the query not reinvent features in the standard library?
  • Can the query be simplified further (not golfed!)

Reviewer

  • Have all the relevant rule package description files been checked in?
  • Have you verified that the metadata properties of each new query is set appropriately?
  • Do all the unit tests contain both "COMPLIANT" and "NON_COMPLIANT" cases?
  • Are the alert messages properly formatted and consistent with the style guide?
  • Have you run the queries on OpenPilot and verified that the performance and results are acceptable?
    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.
  • Does the query have an appropriate level of in-query comments/documentation?
  • Have you considered/identified possible edge cases?
  • Does the query not reinvent features in the standard library?
  • Can the query be simplified further (not golfed!)

…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
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment thread cpp/common/src/codingstandards/cpp/InitializationContext.qll
Comment thread rules.csv
Comment thread cpp/misra/src/rules/RULE-11-6-1/UninitializedVariable.ql
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants