Skip to content

Conversation

michaelnebel
Copy link
Contributor

@michaelnebel michaelnebel commented Sep 1, 2025

Fix some Ql4Ql violations based on the following checks

  • ql/field-only-used-in-charpred
  • ql/could-be-cast
  • ql/counting-to-zero
  • ql/dataflow-module-naming-convention
  • ql/if-with-none
  • ql/missing-parameter-qldoc
  • ql/misspelling

DCA looks good.

@github-actions github-actions bot added the C++ label Sep 1, 2025
@michaelnebel michaelnebel added the no-change-note-required This PR does not need a change note label Sep 2, 2025
@michaelnebel michaelnebel marked this pull request as ready for review September 2, 2025 13:29
@michaelnebel michaelnebel requested a review from a team as a code owner September 2, 2025 13:29
@Copilot Copilot AI review requested due to automatic review settings September 2, 2025 13:29
@jketema
Copy link
Contributor

jketema commented Sep 2, 2025

The "experimental" crypto stuff should not be touched. That's actively being worked on. Or, it should be a separate PR at the very least so @nicolaswill can review it.

Copilot

This comment was marked as outdated.

@michaelnebel
Copy link
Contributor Author

The "experimental" crypto stuff should not be touched. That's actively being worked on. Or, it should be a separate PR at the very least so @nicolaswill can review it.

Ok, I will split it then.

Comment on lines 832 to 833
* The location spans column `sc` of line `sl` to
* column `ec` of line `el` in file `path`.
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should just rename the predicate arguments here. This makes things less clear.

Comment on lines 2271 to 2272
* The location spans column `sc` of line `sl` to
* column `ec` of line `el` in file `path`.
Copy link
Contributor

Choose a reason for hiding this comment

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

As above, rename the arguments.

count(e.getAChild()) = 0 and
not exists(e.getAChild()) and
Copy link
Contributor

Choose a reason for hiding this comment

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

This is not a library that we test against in DCA, but it is used by the field team e.g., so if we want to change this we need to make sure in some way that it's not changing performance.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Reverting.

/**
* Gets a constructor call, if any.
*/
ConstructorCall getAConstructorCall() {
Copy link
Contributor

Choose a reason for hiding this comment

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

This needs a change note.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok

@@ -164,12 +164,17 @@ predicate valueOccurrenceCount(string value, int n) {
n > 20
}

predicate occurenceCount(Literal lit, string value, int n) {
predicate occurrenceCount(Literal lit, string value, int n) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This needs a change note.

@@ -128,11 +128,18 @@ abstract class LeapYearFieldAccess extends YearFieldAccess {
/**
* Holds if the top-level binary operation includes an addition or subtraction operator with an operand specified by `valueToCheck`.
*/
predicate additionalAdditionOrSubstractionCheckForLeapYear(int valueToCheck) {
predicate additionalAdditionOrSubtractionCheckForLeapYear(int valueToCheck) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This needs a change note.

Comment on lines 18 to 19
* The location spans column `sc` of line `sl` to
* column `ec` of line `el` in file `path`.
Copy link
Contributor

Choose a reason for hiding this comment

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

As earlier, rename the arguments.

Comment on lines +8 to +9
* column `startcol` of line `startline` to column `endcol` of line `endline`
* in file `file`.
Copy link
Contributor

Choose a reason for hiding this comment

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

As earlier, rename the arguments.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you know, if that will cause any problems when this is an external predicate?

Copy link
Contributor

Choose a reason for hiding this comment

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

That's a good question. I honestly don't know. Feel free to ignore this review comment.

Comment on lines +8 to +9
* column `startcol` of line `startline` to column `endcol` of line `endline`
* in file `file`.
Copy link
Contributor

Choose a reason for hiding this comment

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

As above, rename the arguments.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

same question.

Copy link
Contributor

Choose a reason for hiding this comment

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

same answer as above.

@Copilot Copilot AI review requested due to automatic review settings September 4, 2025 10:53
@michaelnebel michaelnebel requested a review from jketema September 4, 2025 10:58
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 fixes several Ql4Ql violations identified by code quality checks for C++ CodeQL queries and libraries. The changes address issues including spelling corrections, parameter documentation improvements, code simplification, and method naming corrections.

Key changes:

  • Fixed spelling errors in comments and documentation
  • Simplified conditional logic in several files
  • Corrected method names and parameter documentation
  • Removed unused variables and improved code structure

Reviewed Changes

Copilot reviewed 34 out of 34 changed files in this pull request and generated no comments.

Show a summary per file
File Description
cpp/ql/src/jsf/4.10 Classes/AV Rule 96.ql Simplified exists statement by removing unused parameter variable
cpp/ql/src/external/MetricFilter.qll Updated parameter names in documentation to match predicate signature
cpp/ql/src/external/DefectFilter.qll Updated parameter names in documentation to match predicate signature
cpp/ql/src/experimental/Security/CWE/CWE-416/UseAfterExpiredLifetime.ql Simplified conditional logic using instanceof check
cpp/ql/src/experimental/Security/CWE/CWE-243/IncorrectChangingWorkingDirectory.ql Fixed parameter name in documentation comments
cpp/ql/src/experimental/Security/CWE/CWE-125/DangerousWorksWithMultibyteOrWideCharacters.ql Added missing parameter documentation
cpp/ql/src/experimental/Security/CWE/CWE-1126/DeclarationOfVariableWithUnnecessarilyWideScope.ql Removed unused field and restructured class logic
cpp/ql/src/experimental/Likely Bugs/RedundantNullCheckParam.ql Simplified count check using exists
cpp/ql/src/definitions.ql Fixed spelling of "behavior"
cpp/ql/src/change-notes/2025-09-03-rename-api.md Added change note documenting deprecated predicates
Multiple library files Various corrections including parameter documentation, method naming, spelling fixes, and code simplification
Comments suppressed due to low confidence (1)

cpp/ql/src/jsf/4.10 Classes/AV Rule 96.ql:1

  • Typo in the message: 'teated' should be 'treated'.
/**

@michaelnebel michaelnebel merged commit 64d68fe into github:main Sep 4, 2025
17 checks passed
@michaelnebel
Copy link
Contributor Author

Thank you for the review @jketema !

@michaelnebel michaelnebel deleted the cpp/ql4ql branch September 4, 2025 12:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C++ documentation no-change-note-required This PR does not need a change note
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants