Skip to content

Improve NumericLiteral exclusion coverage and polish QLDoc wording#1137

Closed
Copilot wants to merge 14 commits into
mainfrom
copilot/fix-review-comment-1135
Closed

Improve NumericLiteral exclusion coverage and polish QLDoc wording#1137
Copilot wants to merge 14 commits into
mainfrom
copilot/fix-review-comment-1135

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Jun 2, 2026

Description

Adds focused unit-test coverage for NumericLiteral exclusions in Cpp14Literal and includes a small follow-up QLDoc wording fix raised in review.

  • Extended cpp/common/test/rules/unsignedintegerliteralsnotappropriatelysuffixed/test.cpp with exclusion-focused cases:
    • User-defined literal argument exclusion (0x80000000_km)
    • Template-instantiation-derived literal exclusion
  • Updated cpp/common/test/rules/unsignedintegerliteralsnotappropriatelysuffixed/UnsignedIntegerLiteralsNotAppropriatelySuffixed.expected line mappings accordingly.
  • Includes an indentation-preserving QLDoc grammar correction in cpp/common/src/codingstandards/cpp/Cpp14Literal.qll:
    • An numeric literal.A numeric literal.

Change request type

  • Release or process automation (GitHub workflows, internal scripts)
  • Internal documentation
  • External documentation
  • Query files (.ql, .qll, .qls or unit tests)
  • External scripts (analysis report or other code shipped as part of a release)

Rules with added or modified queries

  • No rules added
  • Queries have been added for the following rules:
    • rule number here
  • Queries have been modified for the following rules:
    • 5-13-4

Release change checklist

A change note (development_handbook.md#change-notes) is required for any pull request which modifies:

  • The structure or layout of the release artifacts.
  • The evaluation performance (memory, execution time) of an existing query.
  • The results of an existing query in any circumstance.

If you are only adding new rule queries, a change note is not required.

Author: Is a change note required?

  • Yes
  • No

🚨🚨🚨
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.

  • Confirmed

Reviewer: Confirm that either a change note is not required or the change note is required and has been added.

  • Confirmed

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

  • Have all the relevant rule package description files been checked in?
  • Have you verified that the metadata properties of each new query is set appropriately?
  • Do all the unit tests contain both "COMPLIANT" and "NON_COMPLIANT" cases?
  • Are the alert messages properly formatted and consistent with the style guide?
  • Have you run the queries on OpenPilot and verified that the performance and results are acceptable?
    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.
  • Does the query have an appropriate level of in-query comments/documentation?
  • Have you considered/identified possible edge cases?
  • Does the query not reinvent features in the standard library?
  • Can the query be simplified further (not golfed!)

Reviewer

  • Have all the relevant rule package description files been checked in?
  • Have you verified that the metadata properties of each new query is set appropriately?
  • Do all the unit tests contain both "COMPLIANT" and "NON_COMPLIANT" cases?
  • Are the alert messages properly formatted and consistent with the style guide?
  • Have you run the queries on OpenPilot and verified that the performance and results are acceptable?
    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.
  • Does the query have an appropriate level of in-query comments/documentation?
  • Have you considered/identified possible edge cases?
  • Does the query not reinvent features in the standard library?
  • Can the query be simplified further (not golfed!)

mbaluda and others added 8 commits May 19, 2026 23:49
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Michael R Fairhurst <MichaelRFairhurst@github.com>
Copilot AI changed the title [WIP] Fix code based on review comment #1135 Add focused test coverage for NumericLiteral exclusion edge cases Jun 2, 2026
Copilot AI requested a review from mbaluda June 2, 2026 17:38
@mbaluda mbaluda marked this pull request as ready for review June 2, 2026 17:39
Copilot AI review requested due to automatic review settings June 2, 2026 17:39
@mbaluda mbaluda changed the base branch from mbaluda-patch-1 to main June 2, 2026 17:40
Copy link
Copy Markdown
Contributor

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 updates the shared C++ literal modeling to exclude numeric literals originating from user-defined literals and template instantiations (to avoid false positives), and adds regression tests to cover those exclusion edge cases for the “missing U suffix” rule.

Changes:

  • Update Cpp14Literal::NumericLiteral to exclude user-defined literal arguments and literals from template instantiations.
  • Extend the unsignedintegerliteralsnotappropriatelysuffixed test to cover both exclusion scenarios and adjust .expected locations.
  • Add a change note documenting the behavioral change (note: the PR description currently claims no query changes / no change note required, which doesn’t match the diff).
Show a summary per file
File Description
cpp/common/src/codingstandards/cpp/Cpp14Literal.qll Adds exclusions to NumericLiteral to prevent reporting on user-defined literal args and template instantiations.
cpp/common/test/rules/unsignedintegerliteralsnotappropriatelysuffixed/test.cpp Adds two new COMPLIANT test cases covering the new exclusion behavior.
cpp/common/test/rules/unsignedintegerliteralsnotappropriatelysuffixed/UnsignedIntegerLiteralsNotAppropriatelySuffixed.expected Updates expected result locations after inserting new test code.
change_notes/2026-05-21-fix-fp-rule-5-13-4.md Documents the query-result change for the affected rules/queries.

Copilot's findings

  • Files reviewed: 4/4 changed files
  • Comments generated: 3

private import cpp as StandardLibrary
private import codingstandards.cpp.UserDefinedLiteral

/** An numeric literal. */
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@copilot respect the indentation

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 796d608 with an indentation-preserving one-line QLDoc correction in Cpp14Literal.qll.

Comment on lines +8 to +12
private import codingstandards.cpp.UserDefinedLiteral

/** An numeric literal. */
abstract class NumericLiteral extends StandardLibrary::Literal { }
abstract class NumericLiteral extends StandardLibrary::Literal {
NumericLiteral() {
Comment thread change_notes/2026-05-21-fix-fp-rule-5-13-4.md Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copilot AI changed the title Add focused test coverage for NumericLiteral exclusion edge cases Improve NumericLiteral exclusion coverage and polish QLDoc wording Jun 2, 2026
@mbaluda mbaluda closed this Jun 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants