Implement DeadCode6, RULE-0-1-2, shared with A0-1-2.#1034
Implement DeadCode6, RULE-0-1-2, shared with A0-1-2.#1034MichaelRFairhurst wants to merge 7 commits intomainfrom
Conversation
Uses new shared library format templates.
There was a problem hiding this comment.
Pull request overview
Implements MISRA C++:2023 RULE-0-1-2 by introducing a shared unused-return-value implementation that is reused between AUTOSAR A0-1-2 and the new MISRA rule package, along with updated metadata and tests.
Changes:
- Added shared
UnusedReturnValuerule library (.qll) plus a common test query and expected output. - Refactored AUTOSAR
A0-1-2to use the shared implementation and renamed the query toUnusedReturnValueAutosar.ql. - Added MISRA
RULE-0-1-2query/package (DeadCode6) and wired it into exclusions metadata (RuleMetadata.qll) andrules.csv.
Reviewed changes
Copilot reviewed 18 out of 18 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| rules.csv | Updates RULE-0-1-2 mapping to new DeadCode6 package. |
| rule_packages/cpp/DeadCode6.json | Adds new rule package metadata for MISRA RULE-0-1-2. |
| rule_packages/cpp/DeadCode.json | Updates AUTOSAR unused-return-value query metadata to use shared implementation + new short name. |
| cpp/misra/test/rules/RULE-0-1-2/UnusedReturnValueMisraCpp.testref | Points MISRA rule test to the common shared test query. |
| cpp/misra/src/rules/RULE-0-1-2/UnusedReturnValueMisraCpp.ql | New MISRA RULE-0-1-2 query using shared library with a MISRA config. |
| cpp/common/test/rules/unusedreturnvalue/test.cpp | Extends shared test inputs (constructor + brace-init compliant case). |
| cpp/common/test/rules/unusedreturnvalue/UnusedReturnValue.ql | Adds generated common test query wrapper for the shared library. |
| cpp/common/test/rules/unusedreturnvalue/UnusedReturnValue.expected | Adds expected results for the new common shared test query. |
| cpp/common/src/codingstandards/cpp/rules/unusedreturnvalue/UnusedReturnValue.qll | Adds shared configurable implementation of unused return value detection. |
| cpp/common/src/codingstandards/cpp/exclusions/cpp/RuleMetadata.qll | Registers new DeadCode6 package in query metadata dispatch. |
| cpp/common/src/codingstandards/cpp/exclusions/cpp/DeadCode6.qll | Adds autogenerated metadata/package wrapper for the MISRA RULE-0-1-2 query. |
| cpp/common/src/codingstandards/cpp/exclusions/cpp/DeadCode.qll | Renames AUTOSAR unused-return-value query wrapper/type/id to *Autosar. |
| cpp/autosar/test/rules/A0-1-2/UnusedReturnValueAutosar.testref | Points AUTOSAR rule test to the common shared test query. |
| cpp/autosar/test/rules/A0-1-2/UnusedReturnValue.qlref | Removes old per-rule test query reference. |
| cpp/autosar/test/rules/A0-1-2/UnusedReturnValue.expected | Removes old per-rule expected output (now uses common expected). |
| cpp/autosar/src/rules/A0-1-2/UnusedReturnValueAutosar.ql | New AUTOSAR A0-1-2 query using the shared library with an AUTOSAR config. |
| cpp/autosar/src/rules/A0-1-2/UnusedReturnValue.ql | Removes old inline AUTOSAR implementation in favor of shared library. |
| change_notes/2026-02-10-share-autosar-0-1-2.md | Adds change note documenting the refactor/rename. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
cpp/common/src/codingstandards/cpp/rules/unusedreturnvalueshared/UnusedReturnValueShared.qll
Show resolved
Hide resolved
|
Failing CI/CD until #1035 lands, but I can revert the shared format to the old style in order to merge this PR if that's preferred. |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 18 out of 18 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // Overloaded (i.e. user defined) operators should behave in the same way as built-in operators, | ||
| // so the rule does not require the use of the return value | ||
| not f instanceof Operator and |
There was a problem hiding this comment.
Operator is referenced in not f instanceof Operator, but this file does not import codingstandards.cpp.Operator, so the query will fail to compile. Add the missing import (or replace Operator with the correct type from an already-imported library).
| Query unusedReturnValueAutosarQuery() { | ||
| //autogenerate `Query` type | ||
| result = | ||
| // `Query` type for `unusedReturnValue` query | ||
| TQueryCPP(TDeadCodePackageQuery(TUnusedReturnValueQuery())) | ||
| // `Query` type for `unusedReturnValueAutosar` query | ||
| TQueryCPP(TDeadCodePackageQuery(TUnusedReturnValueAutosarQuery())) | ||
| } |
There was a problem hiding this comment.
This package API rename/removal (unusedReturnValueQuery -> unusedReturnValueAutosarQuery) appears to leave existing consumers broken. There are still references to DeadCodePackage::unusedReturnValueQuery() under cpp/common/test/deviations/**/UnusedReturnValue.ql; either update those callers or provide a backward-compatible wrapper/alias to avoid compilation failures.
Uses new shared library format templates.
This will fail CI/CD until #1035 is incorporated. However, I can revert it to the old shared query style if that's preferred.
Description
Implements RULE-0-1-2
Change request type
.ql,.qll,.qlsor unit tests)Rules with added or modified queries
RULE-0-1-2A0-1-2Release 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.