steinuil / black-codeclimate

Convert black --diff output into a Code Climate report
MIT License
0 stars 0 forks source link

Include diff hunk as content/body information in codeclimate report #1

Open duncanmmacleod opened 5 hours ago

duncanmmacleod commented 5 hours ago

I've just discovered this tool, thank you for providing/maintaining it!

It would be great to be able to see the change itself in the codeclimate report; is it possible to include the rendered hunk in the codeclimate report via the content/body key?

I'm not sure how this would work with the current implementation that separates hunks into individual non-context blocks, but if I come up with anything clever I will try and post a PR, if that would be welcome.

steinuil commented 3 hours ago

Interesting, I didn't know this property existed. (Or maybe I just ignored it because GitLab doesn't support it.) I suppose we could go a few different ways about this:

  1. Only display the added/removed lines in the block with no context lines around it. This'd be easy, just render block_lines back into text and put it in the issue object.
  2. Display the added/removed ines in the block with some context lines. This would require collecting a few context and removed lines around the block. This approach would yield a different body for each issue.
  3. Include the whole hunk in each issue. This way you'd also get the @@ -12,+3@@ line at the start of the hunk.

Also since the body key is supposed to be Markdown text, you'd just have to wrap it in ```diff\n...\n```.

You're welcome to send a PR if you want! Otherwise I could also do it, it shouldn't be too complicated.