Add leniency in how positions are handled#1002
Merged
adityasharad merged 2 commits intomainfrom Nov 18, 2021
Merged
Conversation
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
| Math.max(0, loc.startColumn - 1), | ||
| Math.max(0, loc.endLine - 1), | ||
| Math.max(0, loc.endColumn) | ||
| Math.max(1, loc.endColumn) |
Contributor
There was a problem hiding this comment.
Took some staring at, but this change to endColumn looks right.
Why don't we need the same logic for endLine?
Contributor
Author
There was a problem hiding this comment.
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.
extensions/ql-vscode/CHANGELOG.md
Outdated
| - 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) |
Contributor
There was a problem hiding this comment.
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) |
9def0a7 to
56be2ec
Compare
adityasharad
approved these changes
Nov 18, 2021
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
@github/docs-content-codeqlhas been cc'd in all issues for UI or other user-facing changes made by this pull request.