Conversation
There was a problem hiding this comment.
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.qllto 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`: | |||
There was a problem hiding this comment.
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.
| - `A0-1-4`, `RULE-2-7` - `UnusedParameter.ql`: | |
| - `A0-1-4`, `RULE-2-7`, `RULE-0-2-2` - `UnusedParameter.ql`: |
| @@ -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 | |||
There was a problem hiding this comment.
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".
| * @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 |
| { | ||
| "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", |
There was a problem hiding this comment.
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.
| 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 |
There was a problem hiding this comment.
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.
| // 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 |
Description
Makes
UnusedParametersinto a shared module so AUTOSAR / MISRA can have different exceptional cases but otherwise share logic.CI/CD is failing pending #1035
Change request type
.ql,.qll,.qlsor unit tests)Rules with added or modified queries
RULE-0-2-2A0-1-4RULE-2-7Release 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.