Skip to content

Commit 67956d8

Browse files
authored
Merge pull request #735 from hvitved/fix-is-deviated
Fix `isDeviated` predicate
2 parents b8ed7e9 + 9b1667e commit 67956d8

File tree

1 file changed

+15
-12
lines changed

1 file changed

+15
-12
lines changed

cpp/common/src/codingstandards/cpp/deviations/Deviations.qll

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -363,27 +363,30 @@ class DeviationRecord extends XmlElement {
363363
result.getRelativePath() = getAChild("paths").getAChild("paths-entry").getTextValue()
364364
}
365365

366+
private string getADeviationPath0() {
367+
if exists(getPathAContainer())
368+
then
369+
// Use the path, which will be relative to this file, if specified
370+
result = getPathAContainer().getRelativePath()
371+
else (
372+
// Otherwise, if no code identifier was supplied, it applies to the parent container of the
373+
// file itself
374+
not exists(getCodeIdentifier()) and
375+
result = this.getFile().getParentContainer().getRelativePath()
376+
)
377+
}
378+
366379
/** Gets a path to which this deviation applies. */
367380
string getADeviationPath() {
368381
exists(string res |
369-
if exists(getPathAContainer())
370-
then
371-
// Use the path, which will be relative to this file, if specified
372-
res = getPathAContainer().getRelativePath()
373-
else (
374-
// Otherwise, if no code identifier was supplied, it applies to the parent container of the
375-
// file itself
376-
not exists(getCodeIdentifier()) and
377-
res = this.getFile().getParentContainer().getRelativePath()
378-
)
379-
|
382+
res = getADeviationPath0() and
380383
if res = "" then result = "(root)" else result = res
381384
)
382385
}
383386

384387
cached
385388
predicate isDeviated(Query query, string deviationPath) {
386389
query = getQuery() and
387-
deviationPath = getADeviationPath()
390+
deviationPath = getADeviationPath0()
388391
}
389392
}

0 commit comments

Comments
 (0)