mitchspano / sfdx-scan-pull-request

Runs sfdx-scanner on a pull request and generates in-line comments with the findings.
Apache License 2.0
73 stars 25 forks source link

Feature Request: Create Review comments for Pull Request. #45

Closed codefriar closed 1 year ago

codefriar commented 1 year ago

The pull request timeline comments are lovely. I think I'd rather see these comments as review comments, however. The Github api looks to support it. (https://docs.github.com/en/rest/pulls/comments?apiVersion=2022-11-28#create-a-review-comment-for-a-pull-request) but I'm not sure of the LOE needed to implement. It looks like you already have the file, position, etc are already available to you in the context where the timeline comment is being created. this also looks to require a 'side' parameter, but I'm guessing that can be assumed to be 'right' most of the time.

mitchspano commented 1 year ago

The comments which are produced as part of the scan are review comments. Check out the endpoint we are POSTing to when creating the comments:

const endpoint = `${method} /repos/${owner}/${repo}/${
      prNumber ? `pulls/${prNumber}` : `commits/${context.sha}`
    }/comments`;

It's the same endpoint as mentioned in the documentation shared above.

The other kind of comment is called an "Issue Comment" and those can show up on the timeline when a PR number is referenced in a comment on an issue - something like:

The fix for this is included in PR #12345 and should be ready before the end of this week.

Those comments will show up on the PR's timeline, but are not explicitly review comments.