tomasbjerre / violation-comments-to-github-lib

A library for commenting GitHub with violations from static code analyzer reports.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

violations on unmodified parts of file

abrahamvarricatt opened this issue · comments

I'm getting too many violation comments! Yesterday, I tried to integrate the jenkins plugin on an older code-base. This is a 4+ year project and I'm probably the first developer to even propose the idea of lint checking. As a result, our lint tool (pylint) reports a LOT of issues. By itself, this is fine, but when paired with the violation-comments-to-github jenkins plugin, the pull request is flooded with comments from areas of code I'd rather not touch.

Ideally, if I made changes to lines 30-50, it makes a lot of sense to see violation reports concerning those lines. To see reports about lines 150-200 is noise and I doubt if I can convince the others on my team to consider using this plugin for long. Is it possible to limit the comments to just modified parts of the code?

To demonstrate what I'm talking about, I rented a server (single instance, ubuntu 14.04 64-bit), installed jenkins on it and made the following pull request on a dummy project,

abrahamvarricatt/hello_pylint#3

If you look at the 'files changed' section of that pull request (and uncheck 'show notes') you'll see that I've only edited lines 9-16. But I'm getting comments about line 1,3 and 4 referenced on line 6.

Alongside this, I have another concern. Here is a screenshot of the project configuration,
project config

Please note that Oauth2 is NOT configured and that the options for 'one comment per violation' and 'comment only changed part of files' have been checked. Now, please have a look at the console output for this build,


---
--- Jenkins Violation Comments to GitHub ---

---
gitHubUrl: https://api.github.com/
repositoryOwner: abrahamvarricatt
repositoryName: hello_pylint
pullRequestId: 3
username: false
password: false
oAuth2Token: true
createSingleFileComments: true
createCommentWithAllSingleFileComments: false
commentOnlyChangedContent: false
Running Jenkins Violation Comments To GitHub
Will comment 3

it claims to be using oAuth2 and that commentOnlyChangedContent is false (shouldn't it be true?). Here's a direct link,
http://luffy.abraham-v.com:8080/job/hello_pylint_demo/15/console

If it would help, I can provide (via email) the admin credentials for the jenkins server. (its a temp system)

I just made a relese of the jenkins plugin (1.7) with a fix for this. Should be available in jenkins update site within a few hours!

Awesome! 👍

From the project commit history, I guess this is the fix?
jenkinsci/violation-comments-to-github-plugin@d4ff698

I probably should have waited, but wanted to test this out immediately and since I have a disposable jenkins server+project decided to do just that. Some searching led me to the plugin-builder here - https://jenkins.ci.cloudbees.com/job/plugins/

Which led me to - https://jenkins.ci.cloudbees.com/job/plugins/job/violation-comments-to-github-plugin/ and the left menu 'modules' let me to this page,
https://jenkins.ci.cloudbees.com/job/plugins/job/violation-comments-to-github-plugin/org.jenkins-ci.plugins$violation-comments-to-github/

I downloaded the violation-comments-to-github-1.8-SNAPSHOT.hpi file from there and installed on my jenkins server via the upload menu. A quick update on my github project brings us all to this,
abrahamvarricatt/hello_pylint#3

The comments are coming ONLY for my changes! The other stuff is ignored! 💯 At last! Something I can sell to the rest of my team. :)

And of further interest here is the console output,

---
--- Jenkins Violation Comments to GitHub ---
---
gitHubUrl: https://api.github.com/
repositoryOwner: abrahamvarricatt
repositoryName: hello_pylint
pullRequestId: 3
username: true
password: true
oAuth2Token: false
createSingleFileComments: true
createCommentWithAllSingleFileComments: false
commentOnlyChangedContent: true
Running Jenkins Violation Comments To GitHub
Will comment 3

@tomasbjerre - Can we please leave this issue open for another day or two? I want to wait for the official update from the jenkins site, install it on my company's internal jenkins server and see how the others on my team react. I'll report back within that time-frame, after which we can close this up?

Nice =) Yes lets keep it open.

Alright, an update - I've got version 1.8 from the official channels running on my company's jenkins server. The github comments are coming up only for violations to the parts of the file I'm editing - things working well and good. :)

Thanks for all the help @tomasbjerre ! :)