- Notifications
You must be signed in to change notification settings - Fork70
Implement "Statements" package#938
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
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.
This is really coming along and looking really good!!
cpp/misra/src/rules/RULE-9-5-1/LegacyForStatementsShouldBeSimple.ql OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
cpp/misra/src/rules/RULE-9-5-1/LegacyForStatementsShouldBeSimple.ql OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
cpp/misra/src/rules/RULE-9-5-1/LegacyForStatementsShouldBeSimple.ql OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
cpp/misra/src/rules/RULE-9-5-1/LegacyForStatementsShouldBeSimple.ql OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
cpp/misra/src/rules/RULE-9-5-1/LegacyForStatementsShouldBeSimple.ql OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
cpp/misra/src/rules/RULE-9-5-1/LegacyForStatementsShouldBeSimple.ql OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
cpp/misra/src/rules/RULE-9-5-1/LegacyForStatementsShouldBeSimple.ql OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
cpp/misra/src/rules/RULE-9-5-1/LegacyForStatementsShouldBeSimple.ql OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
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 implements the "Statements" package for the MISRA C++-2023 coding standards, adding three new query rules for analyzing statement structures in C++ code.
- Added rule implementations for RULE-9-4-2, RULE-9-5-1, and RULE-9-5-2
- Added comprehensive test files with both compliant and non-compliant examples
- Created supporting library code for analyzing increment operations and loop conditions
Reviewed Changes
Copilot reviewed 17 out of 17 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| rule_packages/cpp/Statements.json | Package configuration defining metadata and properties for the three new statement rules |
| cpp/misra/src/rules/RULE-9-4-2/AppropriateStructureOfSwitchStatement.ql | Query implementation to check proper switch statement structure |
| cpp/misra/src/rules/RULE-9-5-1/LegacyForStatementsShouldBeSimple.ql | Query implementation to enforce simple legacy for-loop patterns |
| cpp/misra/src/rules/RULE-9-5-2/ForRangeInitializerAtMostOneFunctionCall.ql | Query implementation to limit function calls in range-based for initializers |
| cpp/misra/test/rules/RULE-9-/ | Test files and expected results for all three rules |
| cpp/common/src/codingstandards/cpp/exclusions/cpp/Statements.qll | Auto-generated exclusion metadata for the new package |
| cpp/common/src/codingstandards/cpp/exclusions/cpp/RuleMetadata.qll | Updated metadata registry to include Statements package |
| cpp/common/src/codingstandards/cpp/ast/Increment.qll | New library for analyzing increment/decrement operations |
| cpp/common/src/codingstandards/cpp/Loops.qll | Extended loop analysis with LegacyForLoopCondition class |
Comments suppressed due to low confidence (1)
rule_packages/cpp/Statements.json:1
- Fixed typo 'that that' should be 'that'.
{Tip: Customize your code reviews with copilot-instructions.md.Create the file orlearn how to get started.
Uh oh!
There was an error while loading.Please reload this page.
cpp/misra/src/rules/RULE-9-4-2/AppropriateStructureOfSwitchStatement.ql OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…github/codeql-coding-standards into jeongsoolee09/MISRA-C++-2023-Statements
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.
This is looking really good. Every time I go through the code again, I'm really impressed with the overall organization and clarity. Nicely done!
Let me know if these next couple suggestions are unclear, we're so close! :)
cpp/misra/src/rules/RULE-9-5-1/LegacyForStatementsShouldBeSimple.ql OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
This refined definition can handle more cases than the previous onethat only looked into the loop body, and better matches the descriptionin the comment above.
This is to cover the cases where the pointers areconstant but the data behind it can be mutatedthrough it.
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.
Great, I believe we should just add tests for these two cases and ensure they pass, and then I think we're good!
for (int i = 0; f(i) < 10; ++i) {}// andvoid reject(int &args...) {}void accept(const int &args...) {}for(int i = 0; i < 10; ++i) reject(i); // non compliantfor(int i = 0; i < 10; ++i) accept(i); // compliantUh oh!
There was an error while loading.Please reload this page.
🎉 🎉 🎉 🍾 🍾 🎉 🎉 🎉 👏 L 👏 G 👏 T 👏 M 👏 !!! |
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.
🥳
a612c2cUh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Description
This PR implements the
Statementspackage.Change request type
.ql,.qll,.qlsor unit tests)Rules with added or modified queries
RULE-9-4-2RULE-9-5-1RULE-9-5-2Release 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 ofshared 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.