Skip to content

C++: SloppyGlobal: Don't alert on template instantiations, only the template #20232

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

Merged
merged 5 commits into from
Aug 18, 2025

Conversation

igfoo
Copy link
Contributor

@igfoo igfoo commented Aug 15, 2025

No description provided.

@github-actions github-actions bot added the C++ label Aug 15, 2025
@igfoo igfoo added the no-change-note-required This PR does not need a change note label Aug 15, 2025
@igfoo igfoo marked this pull request as ready for review August 15, 2025 10:49
@igfoo igfoo requested a review from a team as a code owner August 15, 2025 10:49
@Copilot Copilot AI review requested due to automatic review settings August 15, 2025 10:49
Copy link
Contributor

@Copilot Copilot AI left a 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 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 VariableTemplateInstantiation instances
  • 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.

Copy link
Contributor

@jketema jketema left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

@igfoo igfoo removed the no-change-note-required This PR does not need a change note label Aug 15, 2025
@igfoo igfoo merged commit fd020b5 into github:main Aug 18, 2025
17 checks passed
@igfoo igfoo deleted the igfoo/SloppyGlobal branch August 18, 2025 10:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants