-
Notifications
You must be signed in to change notification settings - Fork 73
Add package linkage 2 #1018
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 package linkage 2 #1018
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 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
externkeyword
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 |
Copilot
AI
Jan 26, 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 message contains a spelling error: "Defintion" should be "Definition".
| " that lead to One Defintion Rule violation." and | |
| " that lead to One Definition Rule violation." and |
| 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 |
Copilot
AI
Jan 26, 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 method isDeeplyConstBelow does not exist. The correct method name is isDeeplyConst. This will cause a compilation error.
| not decl.getDeclaration().(Variable).getType().(PointerOrArrayType).isDeeplyConstBelow() and | |
| not decl.getDeclaration().(Variable).getType().(PointerOrArrayType).isDeeplyConst() and |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Description
add package linkage2.
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.