Repository navigation
fix(scan): keep reviews whose strings contain unmatched braces - #97
Open
JakeHuneau wants to merge 1 commit into
Open
JakeHuneau wants to merge 1 commit into
JakeHuneau wants to merge 1 commit into
Conversation
extractJson matched the last } with a { by counting braces, so a comment
body such as "impl Foo {" shifted the match onto an inner comment object
and the valid review failed to parse. Take the earliest { whose slice up
to the last } parses as JSON, and keep the brace count as the fallback
for output that is not valid JSON.
Fixes DataDog#91
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.
Fixes #91.
extractJsonpaired the last}with a{by counting braces backward. Braces inside JSON strings count too, so a comment body with an unmatched brace (for exampleimpl Foo {) moved the match onto an inner comment object, and a valid review failed to parse with "Unexpected non-whitespace character after JSON".It now takes the earliest
{whose slice up to the last}parses as JSON. Prose before the block still gets skipped, because a slice that starts in the prose doesn't parse. If no slice parses, it falls back to the old brace count, so malformed output still reaches the caller's parse error as before.Tests:
{or}, both bare and fenced after prose with braces. These fail onmain.npm test: 120 passing.