Skip to content

Fix isDeviated predicate #735

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 1 commit into from
Oct 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 15 additions & 12 deletions cpp/common/src/codingstandards/cpp/deviations/Deviations.qll
Original file line number Diff line number Diff line change
Expand Up @@ -363,27 +363,30 @@ class DeviationRecord extends XmlElement {
result.getRelativePath() = getAChild("paths").getAChild("paths-entry").getTextValue()
}

private string getADeviationPath0() {
if exists(getPathAContainer())
then
// Use the path, which will be relative to this file, if specified
result = getPathAContainer().getRelativePath()
else (
// Otherwise, if no code identifier was supplied, it applies to the parent container of the
// file itself
not exists(getCodeIdentifier()) and
result = this.getFile().getParentContainer().getRelativePath()
)
}

/** Gets a path to which this deviation applies. */
string getADeviationPath() {
exists(string res |
if exists(getPathAContainer())
then
// Use the path, which will be relative to this file, if specified
res = getPathAContainer().getRelativePath()
else (
// Otherwise, if no code identifier was supplied, it applies to the parent container of the
// file itself
not exists(getCodeIdentifier()) and
res = this.getFile().getParentContainer().getRelativePath()
)
|
res = getADeviationPath0() and
if res = "" then result = "(root)" else result = res
)
}

cached
predicate isDeviated(Query query, string deviationPath) {
query = getQuery() and
deviationPath = getADeviationPath()
deviationPath = getADeviationPath0()
}
}
Loading