Skip to content

Conversation

@knewbury01
Copy link
Collaborator

@knewbury01 knewbury01 commented Jan 26, 2026

Description

add package linkage2.

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

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

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 a new "Linkage2" rule package containing queries for MISRA C++ 2023 rules RULE-6-2-4 and RULE-6-5-2, while refactoring the existing AUTOSAR A3-1-1 query to use a shared implementation for one-definition-rule violations.

Changes:

  • Created shared query library for one-definition-rule violations that both AUTOSAR A3-1-1 and MISRA RULE-6-2-4 now use
  • Added new query for MISRA RULE-6-5-2 to check that internal linkage is specified appropriately
  • Fixed A3-1-1 to properly detect external linkage using the linkage library instead of just checking for the extern keyword

Reviewed changes

Copilot reviewed 22 out of 23 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
rules.csv Updated package assignments for RULE-6-2-4 and RULE-6-5-2 to use new Linkage2 package
rule_packages/cpp/Linkage2.json Defines metadata for new RULE-6-2-4 and RULE-6-5-2 queries
rule_packages/cpp/Includes.json Added shared_implementation_short_name for A3-1-1
cpp/misra/test/rules/RULE-6-5-2/* Test files for new RULE-6-5-2 query with compliant and non-compliant cases
cpp/misra/test/rules/RULE-6-2-4/ViolationsOfOneDefinitionRuleMisra.testref Test reference pointing to shared test implementation
cpp/common/test/rules/violationsofonedefinitionrule/* Common test implementation for violations of one definition rule
cpp/misra/src/rules/RULE-6-5-2/InternalLinkageSpecifiedAppropriately.ql New query checking for appropriate internal linkage specification
cpp/misra/src/rules/RULE-6-2-4/ViolationsOfOneDefinitionRuleMisra.ql New MISRA query using shared implementation
cpp/common/src/codingstandards/cpp/rules/violationsofonedefinitionrule/ViolationsOfOneDefinitionRule.qll Shared query library for one-definition-rule violations
cpp/common/src/codingstandards/cpp/exclusions/cpp/RuleMetadata.qll Updated to include Linkage2 package
cpp/common/src/codingstandards/cpp/exclusions/cpp/Linkage2.qll New exclusions file for Linkage2 package
cpp/autosar/test/rules/A3-1-1/* Updated to use shared test implementation
cpp/autosar/src/rules/A3-1-1/ViolationsOfOneDefinitionRule.ql Refactored to use shared query library
change_notes/2026-01-26-a3-1-1-extern-to-full.md Documents behavior change in A3-1-1 query
.vscode/tasks.json Added Linkage1 and Linkage2 to package list
Comments suppressed due to low confidence (5)

cpp/misra/test/rules/RULE-6-5-2/test.cpp:9

  • The comment contains a spelling error: "NON_COMPILANT" should be "NON_COMPLIANT".
static int i2; // NON_COMPILANT  - prefer to not use static as it is redundant

cpp/misra/test/rules/RULE-6-5-2/test.cpp:1

  • The comment contains a spelling error: "NON_COMPILANT" should be "NON_COMPLIANT".
static void f(); // NON_COMPILANT - prefer to use an anonymous namespace

cpp/misra/test/rules/RULE-6-5-2/test.cpp:4

  • The comment contains a spelling error: "COMPILANT" should be "COMPLIANT".
void f1();        // COMPILANT

cpp/misra/test/rules/RULE-6-5-2/test.cpp:7

  • The comment contains a spelling error: "COMPILANT" should be "COMPLIANT".
int i;         // COMPILANT

cpp/misra/test/rules/RULE-6-5-2/test.cpp:8

  • The comment contains a spelling error: "NON_COMPILANT" should be "NON_COMPLIANT".
extern int i1; // NON_COMPILANT

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

secondmessage = decl.getFile().getBaseName() and
message =
"Header file $@ contains " + case + " " + decl.getName() +
" that lead to One Defintion Rule violation." and
Copy link

Copilot AI Jan 26, 2026

Choose a reason for hiding this comment

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

The message contains a spelling error: "Defintion" should be "Definition".

Suggested change
" that lead to One Defintion Rule violation." and
" that lead to One Definition Rule violation." and

Copilot uses AI. Check for mistakes.
hasInternalLinkage(decl.getDeclaration()) and
//exclusions as per rule for const and constexpr Variables
not decl.getDeclaration().(Variable).getUnderlyingType().isConst() and
not decl.getDeclaration().(Variable).getType().(PointerOrArrayType).isDeeplyConstBelow() and
Copy link

Copilot AI Jan 26, 2026

Choose a reason for hiding this comment

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

The method isDeeplyConstBelow does not exist. The correct method name is isDeeplyConst. This will cause a compilation error.

Suggested change
not decl.getDeclaration().(Variable).getType().(PointerOrArrayType).isDeeplyConstBelow() and
not decl.getDeclaration().(Variable).getType().(PointerOrArrayType).isDeeplyConst() and

Copilot uses AI. Check for mistakes.
mbaluda and others added 3 commits January 27, 2026 11:00
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.

2 participants