jenkinsci / violation-comments-to-gitlab-plugin

Comments GitLab merge requests with static code analyzer findings.
https://plugins.jenkins.io/violation-comments-to-gitlab
MIT License
20 stars 4 forks source link

Support commentOnlyChangedContentContext #19

Closed WonderCsabo closed 3 years ago

WonderCsabo commented 5 years ago

Expected: if the commentOnlyChangedContent parameter is set to true, only the violations for changed lines should be reported.

Actual: it seems if the violation is inside the diff, it is still reported, despite if the line was actually changed or not.

Example:

screenshot 2019-03-04 at 15 35 44

You can see that a violation was reported for line 5 (the line with ellipsis), but that line actually was not changed by the commits.

tomasbjerre commented 5 years ago

This is intended. I would argue that it is likely that a changed line may introduce a problem that is reported on a nearby line. Not necessarily reported on the exact line that was changed.

Any violation within the patch, reported by GitLab, will be reported. The patch being what a human would see when viewing the merge request diff in the GUI. Implemented like this:

WonderCsabo commented 5 years ago

Could be relevant, but could be totally irrelevant. You cannot know. Since the flag is about the changed code, IMHO it should be reported for the changed code, and not other, nearby parts as well.

tomasbjerre commented 5 years ago

The Bitbucket Server plugin has a commentOnlyChangedContentContext config that can be set to 1 to only comment on the exact line. That feature can be added here to solve this issue.

WonderCsabo commented 5 years ago

Good idea!

shyingsheng commented 5 years ago

Hi Tomas, Do you have the ETA when this enhancement can be implemented?

tomasbjerre commented 5 years ago

No. Pull requests are welcome.

Kylmakalle commented 3 years ago

Looks like it's supported now https://github.com/jenkinsci/violation-comments-to-gitlab-plugin/commit/7cbdf2565be1ea05b1b2c1aba1b990efbee4aec1

tomasbjerre commented 3 years ago

yes this is available now.

shyingsheng commented 3 years ago

Hi Tomas, Firstly very happy to know that this enhancement was implemented in 2.49. But in release page, latest one is 2.47, how can I upgrade to 2.49 via jenkins plugin manager?

tomasbjerre commented 3 years ago

I made a new release now, should be available within hours.

shyingsheng commented 3 years ago

Many many thanks, new release is available now.