Graph viewer: edges ordered by wrong attribute

Open
#1,332 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
typescript
Domain
frontend

Research direction

Start by reproducing the graph query in the issue and locate the graph viewer code that applies semmle.order to nodes and edges. Confirm that root nodes remain ordered descending while each set of child nodes follows the edges predicate's ascending order, then add or update a regression test if the project has coverage for graph ordering.

Written by the indexing model from the issue text.

Description

bug VSCode

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

Dominant language
TypeScript
Stars
539
Forks
240
Avg merge
2d 6h
Merged PRs (30d)
29

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from github/vscode-codeql

All issues in github/vscode-codeql

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.