vscode-codeql icon indicating copy to clipboard operation
vscode-codeql copied to clipboard

Graph viewer: edges ordered by wrong attribute

Open nickrolfe opened this issue 3 years ago • 0 comments

The graph viewer displays child nodes in the order specified by the semmle.order attribute on the nodes predicate, when it should display them in the order specified by the semmle.order attribute on the edges predicate.

This can be demonstrated with the following graph query:

/**
 * @kind graph
 * @id foo
 */
query predicate nodes(string node, string attr, string val) {
  exists(int i | i = [0 .. 5] and node = i.toString() |
    attr = "semmle.label" and val = node
    or
    attr = "semmle.order" and val = (-i).toString()
  )
}

query predicate edges(string a, string b, string attr, string val) {
  (
    a = "0" and b = ["1", "2"]
    or
    a = "3" and b = ["4", "5"]
  ) and
  (
    attr = "semmle.label" and val = ""
    or
    attr = "semmle.order" and val = b.toString()
  )
}

The nodes predicate specifies that nodes should be ordered in descending order (-i), while the edges predicate specifies that edges should be ordered in ascending order.

In the following screenshot you can see that, while the two subgraphs appear to be ordered correctly, i.e. in descending order of the root node's value (3, then 0), the child nodes also appear left-to-right in descending order (5, 4; 2, 1), which suggests to me that they are also being ordered according to the attribute in the nodes predicate. I would expect them to appear in ascending order.

image

Version

VS Code: 1.66.2 CodeQL extension: 1.6.5

nickrolfe avatar May 04 '22 14:05 nickrolfe