-
Notifications
You must be signed in to change notification settings - Fork 1.8k
C++: Fix some Ql4Ql violations. #20325
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
Conversation
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 |
Ok, I will split it then. |
441e5a3
to
5199829
Compare
5199829
to
83d53ba
Compare
* The location spans column `sc` of line `sl` to | ||
* column `ec` of line `el` in file `path`. |
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.
I think we should just rename the predicate arguments here. This makes things less clear.
* The location spans column `sc` of line `sl` to | ||
* column `ec` of line `el` in file `path`. |
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.
As above, rename the arguments.
count(e.getAChild()) = 0 and | ||
not exists(e.getAChild()) and |
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 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.
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.
Reverting.
/** | ||
* Gets a constructor call, if any. | ||
*/ | ||
ConstructorCall getAConstructorCall() { |
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 needs a change note.
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.
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) { |
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 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) { |
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 needs a change note.
* The location spans column `sc` of line `sl` to | ||
* column `ec` of line `el` in file `path`. |
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.
As earlier, rename the arguments.
* column `startcol` of line `startline` to column `endcol` of line `endline` | ||
* in file `file`. |
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.
As earlier, rename the arguments.
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.
Do you know, if that will cause any problems when this is an external predicate?
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.
That's a good question. I honestly don't know. Feel free to ignore this review comment.
* column `startcol` of line `startline` to column `endcol` of line `endline` | ||
* in file `file`. |
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.
As above, rename the arguments.
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.
same question.
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.
same answer as above.
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 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'.
/**
Thank you for the review @jketema ! |
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.