Hi Andrii,

We present line numbers on the left and the right sides, but when placing a
comment we use row numbers, in order to be able to have comments that span
left and right sides. You'd need to have code that pulls down the opcodes
for the diff and finds the corresponding row number for the line numbers
you care about.

Review Bot, our automated code review tool, does this, and you can see some
of its code here:

https://github.com/reviewboard/ReviewBot/blob/master/bot/reviewbot/processing/review.py#L155

This is executing on the Review Board side, though. To get those "chunks"
it's operating on, you'd need to use this API:

https://www.reviewboard.org/docs/manual/2.5/webapi/2.0/resources/file-diff/

You'd need to use the `Accept:
application/vnd.reviewboard.org.diff.data+json` header to get the response
containing the opcodes. You'll also need to locate the appropriate filediff
resource from the list of files for the particular diff revision you're
reviewing (
https://www.reviewboard.org/docs/manual/2.5/webapi/2.0/resources/file-diff-list/#webapi2.0-file-diff-list-resource
).

Obviously this is a bit of work, but it should be doable. Another avenue is
to play with getting Review Bot (from the release-0.2.x branch) installed.
Review Bot is built to kick off automated code reviews when changes are
posted. You integrate with it by writing "tools" that run some command or
something to review the code, and then represent any errors (with the
generated filenames, line numbers, and error messages) as a response to
Review Bot. Then, Review Bot will turn those into reviews on the review
request, handling the line number stuff for you.

Now, this is a prototype, and won't be receiving any more fixes, but the
master branch is under active development for Review Board 3.0. When 3.0
ships, Review Bot 1.0 will also ship, and you'll be in a better position to
integrate with it.

Christian

On Fri, Aug 4, 2017 at 4:08 AM, Andrii Artemenko <[email protected]
> wrote:

> Hi all,
>
> When I use web UI of the ReviewBoard to see commit diff there are two
> frames: how code looked before changes(left frame) and how it looks
> after(right frame). Each frame has it own line numbering.
>
> I use the Sonar to scan code after changes and I want to add it's comments
> to the review using API( /api/review-requests/{review_
> request_id}/reviews/{review_id}/diff-comments/).
>
> Sonar returns line numbers corresponding the right side, but when I use
> API to create the comment for diff it sticks my comment corresponding to
> the left frame numbering.
> I.e. it looks like the Sonar comments wrong lines.
>
> How can I post diff comments using line numbering from the right frame?
>
> Cheers,
> Andrii
>
> --
> Supercharge your Review Board with Power Pack:
> https://www.reviewboard.org/powerpack/
> Want us to host Review Board for you? Check out RBCommons:
> https://rbcommons.com/
> Happy user? Let us know! https://www.reviewboard.org/users/
> ---
> You received this message because you are subscribed to the Google Groups
> "reviewboard" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Christian Hammond
President/CEO of Beanbag <https://www.beanbaginc.com/>
Makers of Review Board <https://www.reviewboard.org/>

-- 
Supercharge your Review Board with Power Pack: 
https://www.reviewboard.org/powerpack/
Want us to host Review Board for you? Check out RBCommons: 
https://rbcommons.com/
Happy user? Let us know! https://www.reviewboard.org/users/
--- 
You received this message because you are subscribed to the Google Groups 
"reviewboard" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to