Skip to content

First draft of RULE-0-2-2#1038

Open
MichaelRFairhurst wants to merge 4 commits intomainfrom
michalrfairhurst/package-dead-code-8
Open

First draft of RULE-0-2-2#1038
MichaelRFairhurst wants to merge 4 commits intomainfrom
michalrfairhurst/package-dead-code-8

Conversation

@MichaelRFairhurst
Copy link
Collaborator

@MichaelRFairhurst MichaelRFairhurst commented Feb 14, 2026

Description

Makes UnusedParameters into a shared module so AUTOSAR / MISRA can have different exceptional cases but otherwise share logic.

CI/CD is failing pending #1035

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-0-2-2
  • Queries have been modified for the following rules:
    • A0-1-4
    • RULE-2-7

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!)

Copilot AI review requested due to automatic review settings February 14, 2026 06:22
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 refactors the UnusedParameter queries to use a shared module pattern with signature modules, enabling AUTOSAR and MISRA to have different exceptional cases while sharing core logic. It also adds a new query for MISRA C++ 2023 RULE-0-2-2.

Changes:

  • Refactored UnusedParameter.qll to use a signature module pattern with configurable exclusion logic
  • Added new query RULE-0-2-2 for MISRA C++ 2023 to check for unused named parameters
  • Updated A0-1-4 and RULE-2-7 to use the new shared module pattern with rule-specific exclusions

Reviewed changes

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

Show a summary per file
File Description
cpp/common/src/codingstandards/cpp/rules/unusedparameter/UnusedParameter.qll Refactored to use signature module pattern with configurable excludeParameter predicate
cpp/misra/src/rules/RULE-0-2-2/UnusedParameterMisraCpp.ql New query for MISRA C++ RULE-0-2-2 with exclusion for unnamed parameters in definitions
cpp/autosar/src/rules/A0-1-4/UnusedParameter.ql Updated to use new pattern, excludes virtual functions
c/misra/src/rules/RULE-2-7/UnusedParameter.ql Updated to use new pattern, no custom exclusions
cpp/common/test/rules/unusedparameter/UnusedParameter.ql Updated test query to use new pattern
c/common/test/rules/unusedparameter/UnusedParameter.ql Updated test query to use new pattern
cpp/misra/test/rules/RULE-0-2-2/* New test files for RULE-0-2-2
cpp/autosar/test/rules/A0-1-4/* Updated to use qlref instead of testref, with new test cases
cpp/common/test/rules/unusedparameter/test.cpp Updated comment and expected results to reflect virtual functions now being checked
rule_packages/cpp/DeadCode8.json New rule package metadata for RULE-0-2-2
cpp/common/src/codingstandards/cpp/exclusions/cpp/DeadCode8.qll Generated metadata file for DeadCode8 package
cpp/common/src/codingstandards/cpp/exclusions/cpp/RuleMetadata.qll Added imports and references for DeadCode8
rules.csv Updated RULE-0-2-2 to use DeadCode8 package
change_notes/2026-02-13-refactor-unused-parameter-queries.md Change note documenting the refactoring
Comments suppressed due to low confidence (1)

rule_packages/cpp/DeadCode8.json:24

  • According to rules.csv line 831, RULE-0-2-2 maps to both A0-1-4 (non-virtual functions) and A0-1-5 (virtual functions), meaning it should apply to all named function parameters. The title incorrectly restricts this to "non-virtual functions". Update the title to reflect the actual scope.
      "title": "There shall be no unused named parameters in non-virtual functions."

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@@ -0,0 +1,2 @@
- `A0-1-4`, `RULE-2-7` - `UnusedParameter.ql`:
Copy link

Copilot AI Feb 14, 2026

Choose a reason for hiding this comment

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

The change note mentions only A0-1-4 and RULE-2-7, but this PR also adds a new query for RULE-0-2-2. According to the development handbook guidelines for change notes, the change note should list all queries that have been modified or added. Please add RULE-0-2-2 to the list of affected rules in the change note.

Suggested change
- `A0-1-4`, `RULE-2-7` - `UnusedParameter.ql`:
- `A0-1-4`, `RULE-2-7`, `RULE-0-2-2` - `UnusedParameter.ql`:

Copilot uses AI. Check for mistakes.
@@ -0,0 +1,29 @@
/**
* @id cpp/misra/unused-parameter-misra-cpp
* @name RULE-0-2-2: There shall be no unused named parameters in non-virtual functions
Copy link

Copilot AI Feb 14, 2026

Choose a reason for hiding this comment

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

According to rules.csv line 831, RULE-0-2-2 maps to both A0-1-4 (non-virtual functions) and A0-1-5 (virtual functions), indicating it should apply to all named function parameters. The query name incorrectly states "non-virtual functions" when it should apply to all functions. The name should be updated to remove the "non-virtual" restriction, for example: "There shall be no unused named parameters in functions".

Suggested change
* @name RULE-0-2-2: There shall be no unused named parameters in non-virtual functions
* @name RULE-0-2-2: There shall be no unused named parameters in functions

Copilot uses AI. Check for mistakes.
{
"description": "Unused parameters can indicate a mistake when implementing the function.",
"kind": "problem",
"name": "There shall be no unused named parameters in non-virtual functions",
Copy link

Copilot AI Feb 14, 2026

Choose a reason for hiding this comment

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

According to rules.csv line 831, RULE-0-2-2 maps to both A0-1-4 (non-virtual functions) and A0-1-5 (virtual functions), meaning it should apply to all named function parameters. The query name incorrectly restricts this to "non-virtual functions". Update the name to reflect the actual scope, for example: "There shall be no unused named parameters in functions".

This issue also appears on line 24 of the same file.

Copilot uses AI. Check for mistakes.
void b(int x) {} // NON_COMPLIANT
void c(int) {} // COMPLIANT

// This is a violation of A0-1-4, but not a violation of Rule 0-0-2, so it's
Copy link

Copilot AI Feb 14, 2026

Choose a reason for hiding this comment

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

The comment says "Rule 0-0-2" but should be "RULE-0-2-2" to match the standard naming convention used elsewhere in the codebase.

Suggested change
// This is a violation of A0-1-4, but not a violation of Rule 0-0-2, so it's
// This is a violation of A0-1-4, but not a violation of RULE-0-2-2, so it's

Copilot uses AI. Check for mistakes.
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.

1 participant