-
Notifications
You must be signed in to change notification settings - Fork 73
Add linkage1 package #1016
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Add linkage1 package #1016
Conversation
There was a problem hiding this 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 pull request adds a new "Linkage1" package containing shared implementations for two MISRA-C++-2023 rules (RULE-6-0-2 and RULE-6-5-1). These rules share implementation with existing AUTOSAR rules (A3-1-4 and A3-3-1). The PR refactors existing code to use shared query implementations, migrates tests to common locations, and updates metadata accordingly.
Changes:
- Adds Linkage1 package with shared implementations for external linkage array size and declaration rules
- Refactors AUTOSAR rules A3-1-4 and A3-3-1 to use shared implementations
- Adds MISRA-C++-2023 rules RULE-6-0-2 and RULE-6-5-1 that reuse these shared implementations
Reviewed changes
Copilot reviewed 27 out of 30 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| rules.csv | Updates package assignments for RULE-6-0-2 and RULE-6-5-1 to use new Linkage1 package |
| rule_packages/cpp/Scope.json | Renames short_name to include "Autosar" suffix and adds shared_implementation_short_name |
| rule_packages/cpp/Linkage1.json | New package definition for MISRA-C++-2023 linkage rules |
| rule_packages/cpp/Includes.json | Adds shared_implementation_short_name to existing A3-3-1 rule |
| cpp/misra/test/rules/RULE-6-5-1/ExternalLinkageNotDeclaredInHeaderFileMisra.testref | Test reference pointing to shared test implementation |
| cpp/misra/test/rules/RULE-6-0-2/ExternalLinkageArrayWithoutExplicitSizeMisra.testref | Test reference pointing to shared test implementation |
| cpp/misra/src/rules/RULE-6-5-1/ExternalLinkageNotDeclaredInHeaderFileMisra.ql | New MISRA query using shared implementation |
| cpp/misra/src/rules/RULE-6-0-2/ExternalLinkageArrayWithoutExplicitSizeMisra.ql | New MISRA query using shared implementation |
| cpp/common/test/rules/externallinkagenotdeclaredinheaderfile/test.hpp | Shared test header file |
| cpp/common/test/rules/externallinkagenotdeclaredinheaderfile/test.cpp | Shared test implementation with COMPLIANT/NON_COMPLIANT cases |
| cpp/common/test/rules/externallinkagenotdeclaredinheaderfile/ExternalLinkageNotDeclaredInHeaderFile.ql | Shared test query |
| cpp/common/test/rules/externallinkagenotdeclaredinheaderfile/ExternalLinkageNotDeclaredInHeaderFile.expected | Expected test results |
| cpp/common/test/rules/externallinkagearraywithoutexplicitsize/test.cpp | Shared test implementation with COMPLIANT/NON_COMPLIANT cases |
| cpp/common/test/rules/externallinkagearraywithoutexplicitsize/ExternalLinkageArrayWithoutExplicitSize.ql | Shared test query |
| cpp/common/test/rules/externallinkagearraywithoutexplicitsize/ExternalLinkageArrayWithoutExplicitSize.expected | Expected test results |
| cpp/common/src/codingstandards/cpp/rules/externallinkagenotdeclaredinheaderfile/ExternalLinkageNotDeclaredInHeaderFile.qll | Shared implementation for external linkage declaration rule |
| cpp/common/src/codingstandards/cpp/rules/externallinkagearraywithoutexplicitsize/ExternalLinkageArrayWithoutExplicitSize.qll | Shared implementation for array size rule |
| cpp/common/src/codingstandards/cpp/exclusions/cpp/Scope.qll | Renames query to include "Autosar" suffix |
| cpp/common/src/codingstandards/cpp/exclusions/cpp/RuleMetadata.qll | Imports and registers new Linkage1 package |
| cpp/common/src/codingstandards/cpp/exclusions/cpp/Linkage1.qll | New exclusions file for Linkage1 package |
| cpp/autosar/test/rules/A3-3-1/ExternalLinkageNotDeclaredInHeaderFile.testref | Updated to point to shared test |
| cpp/autosar/test/rules/A3-3-1/ExternalLinkageNotDeclaredInHeaderFile.qlref | Removed (migrated to testref) |
| cpp/autosar/test/rules/A3-1-4/test.cpp | Removed (migrated to common tests) |
| cpp/autosar/test/rules/A3-1-4/ExternalLinkageArrayWithoutExplicitSizeAutosar.testref | Updated to point to shared test |
| cpp/autosar/test/rules/A3-1-4/ExternalLinkageArrayWithoutExplicitSize.qlref | Removed (migrated to testref) |
| cpp/autosar/test/rules/A3-1-4/ExternalLinkageArrayWithoutExplicitSize.expected | Removed (migrated to common tests) |
| cpp/autosar/src/rules/A3-3-1/ExternalLinkageNotDeclaredInHeaderFile.ql | Refactored to use shared implementation |
| cpp/autosar/src/rules/A3-1-4/ExternalLinkageArrayWithoutExplicitSizeAutosar.ql | New file using shared implementation (renamed) |
| cpp/autosar/src/rules/A3-1-4/ExternalLinkageArrayWithoutExplicitSize.ql | Removed (renamed to ExternalLinkageArrayWithoutExplicitSizeAutosar.ql) |
| change_notes/2026-01-15-a3-1-4-extern-to-full.md | Change note documenting the refactoring |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| * Introducing a function or object with external linkage outside of a header file can | ||
| * cause developer confusion about its translation unit access semantics. |
Copilot
AI
Jan 15, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The documentation comment describes the wrong issue. This file is about arrays with external linkage declared without explicit size, but the comment describes "Introducing a function or object with external linkage outside of a header file" which is actually the description for the other rule (ExternalLinkageNotDeclaredInHeaderFile). The comment should describe the array size issue instead.
| * Introducing a function or object with external linkage outside of a header file can | |
| * cause developer confusion about its translation unit access semantics. | |
| * Declaring an array with external linkage without explicitly specifying its size | |
| * can lead to unclear or inconsistent expectations about the array's bounds. |
| "' with external linkage doesn't specify the size explicitly." and | ||
| hasExternalLinkage(v) and | ||
| not arrayType.hasArraySize() and | ||
| // Holds is if declEntry is an array variable declaration (not a definition) |
Copilot
AI
Jan 15, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Grammatical error: "Holds is if" should be "Holds if". Remove the word "is".
| // Holds is if declEntry is an array variable declaration (not a definition) | |
| // Holds if declEntry is an array variable declaration (not a definition) |
Description
adds a package for linkage1 - contains 2 rules which are shared implementations
Change request type
.ql,.qll,.qlsor unit tests)Rules with added or modified queries
Release 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.