Skip to content

Add leniency in how positions are handled#1002

Merged
adityasharad merged 2 commits intomainfrom
aeisenberg/location
Nov 18, 2021
Merged

Add leniency in how positions are handled#1002
adityasharad merged 2 commits intomainfrom
aeisenberg/location

Conversation

@aeisenberg
Copy link
Copy Markdown
Contributor

@aeisenberg aeisenberg commented Nov 15, 2021

Previously, positions with end column of 0 were rejected by the
extension. CodeQL positions are supposed to be 1-based, but the CLI
does handle 0-based and negative positions by using character offsets
from the current line start.

Instead of rejecting these kinds of positions, the extension should
handle them as gracefully as possible.

Fixes #999

Replace this with a description of the changes your pull request makes.

Checklist

  • CHANGELOG.md has been updated to incorporate all user visible changes made by this pull request.
  • Issues have been created for any UI or other user-facing changes made by this pull request.
  • [n/a] @github/docs-content-codeql has been cc'd in all issues for UI or other user-facing changes made by this pull request.

Previously, positions with end column of 0 were rejected by the
extension. CodeQL positions are supposed to be 1-based, but the CLI
does handle 0-based and negative positions by using character offsets
from the current line start.

Instead of rejecting these kinds of positions, the extension should
handle them as gracefully as possible.

Fixes #999
@aeisenberg aeisenberg requested a review from a team as a code owner November 15, 2021 22:06
@aeisenberg aeisenberg added the Complexity: Low A good task for newcomers to learn, or experienced team members to complete quickly. label Nov 16, 2021
Math.max(0, loc.startColumn - 1),
Math.max(0, loc.endLine - 1),
Math.max(0, loc.endColumn)
Math.max(1, loc.endColumn)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Took some staring at, but this change to endColumn looks right.
Why don't we need the same logic for endLine?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If endLine is 0, then that indicates the location is fully contained on the first line of the file.

The goal here is not to fix all problematic locations, but just to quickly handle some obviously incorrect ones. I am assuming that vscode itself is able to do better handling of invalid locations than we can here.

- Replace certain control codes (`U+0000` - `U+001F`) with their corresponding control labels (`U+2400` - `U+241F`) in the results view. [#963](https://github.com/github/vscode-codeql/pull/963)
- Allow case-insensitive project slugs for GitHub repositories when adding a CodeQL database from LGTM. [#978](https://github.com/github/vscode-codeql/pull/961)
- Make "Open Referenced File" command accessible from the active editor menu. [#989](https://github.com/github/vscode-codeql/pull/989)
- Add more leniency in how locations are handled. Locations with a 0 for its end column value are no longer rejected. They are treated as the first column in the line. [#1002](https://github.com/github/vscode-codeql/pull/1002)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- Add more leniency in how locations are handled. Locations with a 0 for its end column value are no longer rejected. They are treated as the first column in the line. [#1002](https://github.com/github/vscode-codeql/pull/1002)
- Allow query result locations with 0 as the end column value. These are treated as the first column in the line. [#1002](https://github.com/github/vscode-codeql/pull/1002)

@adityasharad adityasharad merged commit 03d4aca into main Nov 18, 2021
@adityasharad adityasharad deleted the aeisenberg/location branch November 18, 2021 00:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Complexity: Low A good task for newcomers to learn, or experienced team members to complete quickly.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Results whose location.endColumn == 0 are incorrectly linked

2 participants