Skip to content
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

Add leniency in how positions are handled #1002

Merged
merged 2 commits into from
Nov 18, 2021
Merged

Conversation

aeisenberg
Copy link
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
@@ -70,7 +70,7 @@ function resolveFivePartLocation(
Math.max(0, loc.startLine - 1),
Math.max(0, loc.startColumn - 1),
Math.max(0, loc.endLine - 1),
Math.max(0, loc.endColumn)
Math.max(1, loc.endColumn)
Copy link
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
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.

- 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
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