C++: SloppyGlobal: Don't alert on template instantiations, only the template#20232
Merged
igfoo merged 5 commits intogithub:mainfrom Aug 18, 2025
Merged
C++: SloppyGlobal: Don't alert on template instantiations, only the template#20232igfoo merged 5 commits intogithub:mainfrom
igfoo merged 5 commits intogithub:mainfrom
Conversation
We no longer alert on template instantiations, just the template.
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR improves the SloppyGlobal CodeQL query to avoid duplicate alerts when checking for poorly named global variables. The change ensures that only template variable declarations are flagged, not their individual instantiations.
Key changes:
- Modified the SloppyGlobal query logic to exclude
VariableTemplateInstantiationinstances - Added test cases with template variables to verify the behavior
- Updated expected results to show only template declarations are reported
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| cpp/ql/src/Best Practices/SloppyGlobal.ql | Added condition to exclude variable template instantiations from alerts |
| cpp/ql/test/query-tests/Best Practices/SloppyGlobal/main.cpp | Added test cases with template variables and their usage |
| cpp/ql/test/query-tests/Best Practices/SloppyGlobal/SloppyGlobal.expected | Updated expected results to include new test cases |
You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.
jketema
reviewed
Aug 15, 2025
Contributor
jketema
left a comment
There was a problem hiding this comment.
LGTM. One nit and two further things that need to happen:
- Could you please start a traced DCA experiment on this?
- Could you please add a change note?
jketema
approved these changes
Aug 15, 2025
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.
Alerting on instantiations essentially just gives us duplicate alerts