Skip to content

Add Declarations1#1089

Open
knewbury01 wants to merge 5 commits intogithub:mainfrom
knewbury01:knewbury01/misracpp2023-declarations1
Open

Add Declarations1#1089
knewbury01 wants to merge 5 commits intogithub:mainfrom
knewbury01:knewbury01/misracpp2023-declarations1

Conversation

@knewbury01
Copy link
Collaborator

@knewbury01 knewbury01 commented Mar 19, 2026

Description

add RULE-13-3-3, overlaps with/similar to implementation from RULE-8-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-13-3-3
  • 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 Mar 19, 2026
Copilot AI review requested due to automatic review settings March 19, 2026 17:42
Copy link
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

This PR adds CodeQL support for MISRA C++:2023 RULE-13-3-3 by introducing a new query package (Declarations1), integrating it into the exclusions/metadata system, and adding unit tests.

Changes:

  • Register RULE-13-3-3 in rules.csv to point at the new Declarations1 package.
  • Add the new production query DeclarationsOfAFunctionSameParameterName.ql plus package metadata/exclusions wiring.
  • Add a new test directory with .qlref + .expected and test sources.

Reviewed changes

Copilot reviewed 9 out of 10 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
rules.csv Routes RULE-13-3-3 to the new Declarations1 package.
rule_packages/cpp/Declarations1.json Adds rule-package metadata for RULE-13-3-3.
cpp/misra/src/rules/RULE-13-3-3/DeclarationsOfAFunctionSameParameterName.ql Implements the RULE-13-3-3 query logic and message.
cpp/common/src/codingstandards/cpp/exclusions/cpp/Declarations1.qll Adds autogenerated exclusions/metadata wrapper for the new package.
cpp/common/src/codingstandards/cpp/exclusions/cpp/RuleMetadata.qll Integrates Declarations1 into the global query metadata plumbing.
cpp/misra/test/rules/RULE-13-3-3/functions1.cpp Adds test cases (currently has annotation/intent mismatches).
cpp/misra/test/rules/RULE-13-3-3/functions2.cpp Adds test cases (currently has annotation/intent mismatches).
cpp/misra/test/rules/RULE-13-3-3/DeclarationsOfAFunctionSameParameterName.qlref Hooks the test to the production query.
cpp/misra/test/rules/RULE-13-3-3/DeclarationsOfAFunctionSameParameterName.expected Expected results for the query (currently inconsistent with some test annotations).
Comments suppressed due to low confidence (1)

cpp/misra/test/rules/RULE-13-3-3/functions1.cpp:14

  • This is marked NON_COMPLIANT, but the corresponding declaration(s) use the same parameter names (w, h). The .expected file also has no result for f6, so the test annotations and expectations are inconsistent. Either change this to COMPLIANT, or adjust the declarations to actually create a parameter-name mismatch and update .expected accordingly.
a f6(wi w, wi h) { // NON_COMPLIANT
  return (a)w * h;
}

You can also share your feedback on Copilot code review. Take the survey.

@@ -0,0 +1,36 @@
void f1(int a); // COMPLIANT -- same name
void f2(int a); // COMPLIANT -- unnamed is fine
Copy link
Collaborator

@MichaelRFairhurst MichaelRFairhurst left a comment

Choose a reason for hiding this comment

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

Just one missing finding, otherwise looks good!

@mbaluda mbaluda removed their request for review March 19, 2026 19:26
Copy link
Collaborator

@MichaelRFairhurst MichaelRFairhurst left a comment

Choose a reason for hiding this comment

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

LGTM!

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.

3 participants