Skip to content

Declarations3 cpp misra 2023#1099

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

Declarations3 cpp misra 2023#1099
knewbury01 wants to merge 3 commits intogithub:mainfrom
knewbury01:knewbury01/cpp-misra2023-declarations3

Conversation

@knewbury01
Copy link
Copy Markdown
Collaborator

@knewbury01 knewbury01 commented Apr 1, 2026

Description

Added package declarations 3

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-3-1
    • RULE-6-0-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!)

@knewbury01 knewbury01 self-assigned this Apr 1, 2026
Copilot AI review requested due to automatic review settings April 1, 2026 18:14
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 C++ rule package grouping (Declarations3) and wires two MISRA-C++-2023 rules into it, including new/shared query implementations and tests.

Changes:

  • Introduces the Declarations3 rule package and updates rules.csv to route RULE-6-0-1 and RULE-11-3-1 to it.
  • Adds new MISRA query for RULE-11-3-1 and a MISRA wrapper query for RULE-6-0-1 using a new shared implementation (FunctionDeclaredAtBlockScope).
  • Updates shared metadata/exclusions plumbing to include Declarations3, and adds/rewires tests (.expected/.qlref/.testref) accordingly.

Reviewed changes

Copilot reviewed 17 out of 19 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
rules.csv Moves RULE-6-0-1 and RULE-11-3-1 to the Declarations3 package/category.
rule_packages/cpp/Declarations3.json New package descriptor for the two MISRA rules/queries.
rule_packages/cpp/Declarations.json Adds shared_implementation_short_name for M3-1-2 to use the shared implementation.
cpp/misra/src/rules/RULE-6-0-1/BlockScopeFunctionAmbiguous.ql New MISRA query wrapper importing the shared block-scope function declaration implementation.
cpp/misra/src/rules/RULE-11-3-1/VariableDeclaredArrayType.ql New MISRA query detecting variables declared with array type (with exclusions).
cpp/misra/test/rules/RULE-6-0-1/BlockScopeFunctionAmbiguous.testref Points MISRA rule test to shared test query.
cpp/misra/test/rules/RULE-11-3-1/test.cpp New test cases for array-type variable declaration detection.
cpp/misra/test/rules/RULE-11-3-1/VariableDeclaredArrayType.qlref Test query reference to the new MISRA query.
cpp/misra/test/rules/RULE-11-3-1/VariableDeclaredArrayType.expected Expected results for the new MISRA query test.
cpp/common/src/codingstandards/cpp/rules/functiondeclaredatblockscope/FunctionDeclaredAtBlockScope.qll New shared, configurable implementation for “function declared at block scope”.
cpp/common/test/rules/functiondeclaredatblockscope/test.cpp Shared tests for the new shared implementation.
cpp/common/test/rules/functiondeclaredatblockscope/FunctionDeclaredAtBlockScope.ql Generated shared test harness query for the new shared implementation.
cpp/common/test/rules/functiondeclaredatblockscope/FunctionDeclaredAtBlockScope.expected Expected results for the shared test harness query.
cpp/common/src/codingstandards/cpp/exclusions/cpp/RuleMetadata.qll Registers Declarations3 in query metadata/exclusions union.
cpp/common/src/codingstandards/cpp/exclusions/cpp/Declarations3.qll New (generated) Declarations3 query metadata/exclusions package module.
cpp/common/test/includes/standard-library/string_view Extends test stdlib shim to support std::literals::operator""sv.
cpp/autosar/src/rules/M3-1-2/FunctionsDeclaredAtBlockScope.ql Refactors AUTOSAR query to use the new shared implementation.
cpp/autosar/test/rules/M3-1-2/FunctionsDeclaredAtBlockScope.testref Points AUTOSAR rule test to shared test query.
cpp/autosar/test/rules/M3-1-2/FunctionsDeclaredAtBlockScope.qlref Removes direct .qlref test in favor of .testref.

@knewbury01 knewbury01 changed the title Add declarations package 3 cpp misra 2023 Declarations3 cpp misra 2023 Apr 1, 2026
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