Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds three new MISRA C++ 2023 “Banned*” rule packages and their CodeQL implementations/tests, then wires them into the C++ exclusions/metadata and rules.csv mapping.
Changes:
- Add new rule packages
Banned2,Banned3,Banned4and map RULE-10-2-2/10-2-3/10-3-1 to them inrules.csv. - Add new CodeQL queries implementing the three MISRA rules and corresponding unit tests (
.qlref+.expected). - Integrate the new packages into C++ exclusions metadata (
RuleMetadata.qll+ autogeneratedBanned{2,3,4}.qll).
Reviewed changes
Copilot reviewed 22 out of 22 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| rules.csv | Re-points three MISRA C++ rules from Banned to Banned2/3/4. |
| rule_packages/cpp/Banned2.json | Adds package metadata for RULE-10-2-2 query. |
| rule_packages/cpp/Banned3.json | Adds package metadata for RULE-10-2-3 query. |
| rule_packages/cpp/Banned4.json | Adds package metadata for RULE-10-3-1 query. |
| cpp/misra/src/rules/RULE-10-2-2/UnscopedEnumerationsShouldNotBeDeclared.ql | New query for unscoped enums outside class/struct scope. |
| cpp/misra/src/rules/RULE-10-2-3/UnscopedEnumWithoutFixedUnderlyingTypeUsed.ql | New query for uses of unfixed unscoped enums in numeric contexts. |
| cpp/misra/src/rules/RULE-10-3-1/UnnamedNamespacesInHeaderFiles.ql | New query detecting anonymous namespaces in header files. |
| cpp/misra/test/rules/RULE-10-2-2/test.cpp | Test cases for RULE-10-2-2. |
| cpp/misra/test/rules/RULE-10-2-2/UnscopedEnumerationsShouldNotBeDeclared.qlref | Test wiring to production query. |
| cpp/misra/test/rules/RULE-10-2-2/UnscopedEnumerationsShouldNotBeDeclared.expected | Expected results for RULE-10-2-2 tests. |
| cpp/misra/test/rules/RULE-10-2-3/test.cpp | Test cases for RULE-10-2-3. |
| cpp/misra/test/rules/RULE-10-2-3/UnscopedEnumWithoutFixedUnderlyingTypeUsed.qlref | Test wiring to production query. |
| cpp/misra/test/rules/RULE-10-2-3/UnscopedEnumWithoutFixedUnderlyingTypeUsed.expected | Expected results for RULE-10-2-3 tests. |
| cpp/misra/test/rules/RULE-10-3-1/test.hpp | Header fixture containing compliant/non-compliant namespace patterns. |
| cpp/misra/test/rules/RULE-10-3-1/test1.cpp | TU fixture for header anonymous-namespace behavior. |
| cpp/misra/test/rules/RULE-10-3-1/test2.cpp | TU fixture + main for RULE-10-3-1 test setup. |
| cpp/misra/test/rules/RULE-10-3-1/UnnamedNamespacesInHeaderFiles.qlref | Test wiring to production query. |
| cpp/misra/test/rules/RULE-10-3-1/UnnamedNamespacesInHeaderFiles.expected | Expected results for RULE-10-3-1 tests. |
| cpp/common/src/codingstandards/cpp/exclusions/cpp/RuleMetadata.qll | Registers new packages in C++ exclusions metadata wiring. |
| cpp/common/src/codingstandards/cpp/exclusions/cpp/Banned2.qll | Autogenerated exclusion package module for Banned2. |
| cpp/common/src/codingstandards/cpp/exclusions/cpp/Banned3.qll | Autogenerated exclusion package module for Banned3. |
| cpp/common/src/codingstandards/cpp/exclusions/cpp/Banned4.qll | Autogenerated exclusion package module for Banned4. |
cpp/misra/src/rules/RULE-10-2-3/UnscopedEnumWithoutFixedUnderlyingTypeUsed.ql
Outdated
Show resolved
Hide resolved
…ithub/codeql-coding-standards into jeongsoolee09/MISRA-C++-2023-Banned234
For some weird reason clang-format decided that the `&` operator is an address-of unary-operator and not a bitwise-and binary operator.
MichaelRFairhurst
requested changes
Mar 25, 2026
Collaborator
MichaelRFairhurst
left a comment
There was a problem hiding this comment.
Only some comments about static alert, and tags, otherwise LGTM!
cpp/misra/src/rules/RULE-10-2-2/UnscopedEnumerationsShouldNotBeDeclared.ql
Outdated
Show resolved
Hide resolved
cpp/misra/src/rules/RULE-10-2-2/UnscopedEnumerationsShouldNotBeDeclared.ql
Outdated
Show resolved
Hide resolved
cpp/misra/src/rules/RULE-10-2-3/UnscopedEnumWithoutFixedUnderlyingTypeUsed.ql
Show resolved
Hide resolved
cpp/misra/src/rules/RULE-10-2-3/UnscopedEnumWithoutFixedUnderlyingTypeUsed.ql
Show resolved
Hide resolved
cpp/misra/src/rules/RULE-10-2-2/UnscopedEnumerationsShouldNotBeDeclared.ql
Outdated
Show resolved
Hide resolved
mbaluda
requested changes
Mar 26, 2026
cpp/misra/src/rules/RULE-10-2-2/UnscopedEnumerationsShouldNotBeDeclared.ql
Outdated
Show resolved
Hide resolved
cpp/misra/src/rules/RULE-10-2-3/UnscopedEnumWithoutFixedUnderlyingTypeUsed.ql
Show resolved
Hide resolved
MichaelRFairhurst
approved these changes
Mar 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Add package
Banned2,Banned3, andBanned4, which areRULE-10-2-2,RULE-10-2-3, andRULE-10-3-1respectively.Change request type
.ql,.qll,.qlsor unit tests)Rules with added or modified queries
RULE-10-2-2RULE-10-2-3RULE-10-3-1Release 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.