Skip to content

Implement DeadCode6, RULE-0-1-2, shared with A0-1-2.#1034

Open
MichaelRFairhurst wants to merge 7 commits intomainfrom
michaelrfairhurst/package-deadcode-6
Open

Implement DeadCode6, RULE-0-1-2, shared with A0-1-2.#1034
MichaelRFairhurst wants to merge 7 commits intomainfrom
michaelrfairhurst/package-deadcode-6

Conversation

@MichaelRFairhurst
Copy link
Collaborator

@MichaelRFairhurst MichaelRFairhurst commented Feb 11, 2026

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

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

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

Uses new shared library format templates.
Copilot AI review requested due to automatic review settings February 11, 2026 05:11
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

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 UnusedReturnValue rule library (.qll) plus a common test query and expected output.
  • Refactored AUTOSAR A0-1-2 to use the shared implementation and renamed the query to UnusedReturnValueAutosar.ql.
  • Added MISRA RULE-0-1-2 query/package (DeadCode6) and wired it into exclusions metadata (RuleMetadata.qll) and rules.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.

@MichaelRFairhurst
Copy link
Collaborator Author

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.

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

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.

Comment on lines +35 to +37
// 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
Copy link

Copilot AI Feb 11, 2026

Choose a reason for hiding this comment

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

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

Copilot uses AI. Check for mistakes.
Comment on lines 188 to 193
Query unusedReturnValueAutosarQuery() {
//autogenerate `Query` type
result =
// `Query` type for `unusedReturnValue` query
TQueryCPP(TDeadCodePackageQuery(TUnusedReturnValueQuery()))
// `Query` type for `unusedReturnValueAutosar` query
TQueryCPP(TDeadCodePackageQuery(TUnusedReturnValueAutosarQuery()))
}
Copy link

Copilot AI Feb 11, 2026

Choose a reason for hiding this comment

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

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.

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