Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

parsing pylint reports #6

Closed
abrahamvarricatt opened this issue Apr 6, 2016 · 11 comments
Closed

parsing pylint reports #6

abrahamvarricatt opened this issue Apr 6, 2016 · 11 comments

Comments

@abrahamvarricatt
Copy link

Hello Tomas,

I think there is an issue with the pylint (or flake8?) parser. I'm having the following concerns being raised by pylint,

legacy_data/interface.py:26: [W0102(dangerous-default-value), get_data] Dangerous default value {} as argument
legacy_data/fake_models.py:106: [C0330(bad-continuation), ] Wrong hanging indentation (remove 1 space).
legacy_data/fake_models.py:323: [R0912(too-many-branches), set_flight_partialpayment] Too many branches (13/12)

And, try as I might, I can't seem to get the Violation Comments to GitHub Jenkins Plugin to write comments on my pull requests. Investigating the issue, I think its because the format of my reports does not match what you have on the regex. Specifically here,

https://github.com/tomasbjerre/violations-lib/blob/master/src/main/java/se/bjurr/violations/lib/parsers/Flake8Parser.java#L30

Now, I'm not going to ask that you change the regex (though it would be highly appreciated!), I would like some help in figuring it out. With a lot of trial-and-error I kind-of figured out that if I use the following as my msg template in pylint,

msg-template='{path}:{line}:{column} {msg_id} {msg}'

it should match the regex. Here are some sample messages I got for the above,

legacy_data/interface.py:54:12 C0103 Invalid variable name "r"
legacy_data/interface.py:71:0 W0102 Dangerous default value {} as argument
legacy_data/fake_models.py:323:0 R0912 Too many branches (13/12)
legacy_data/fake_models.py:475:11 W0703 Catching too general exception Exception

At least, the online java regex testers says that I got it right. But the comments to github plugin does not detect anything. On jenkins log, it says that it found 0 violations. Which should not be the case.

Can you please help me figure out how to format the lines from pylint?

@tomasbjerre
Copy link
Owner

Here is the format that is expected:
https://github.com/tomasbjerre/violations-lib/blob/master/src/test/resources/flake8/flake8.txt
It is generated like this:
https://github.com/tomasbjerre/violations-test/blob/master/build.sh

@abrahamvarricatt
Copy link
Author

Wow, thanks for the fast reply!

I edited my msg-format to look like this,

msg-template='{path}:{line}: [{msg_id}] {msg}'

So here is how the output comes,

legacy_data/fake_models.py:116: [R0912] Too many branches (18/12)
legacy_data/fake_models.py:116: [R0915] Too many statements (51/50)
legacy_data/fake_models.py:317: [W0703] Catching too general exception Exception

Which (to me) looks like the correct format. But I'm still not getting any comments on my pull request. :(

Here is the output from my jenkins system log,

CHECKSTYLE with pattern 
Apr 06, 2016 11:24:55 AM INFO org.jenkinsci.plugins.jvctg.JvctsLogger doLog
CSSLINT with pattern 
Apr 06, 2016 11:24:55 AM INFO org.jenkinsci.plugins.jvctg.JvctsLogger doLog
LINT with pattern 
Apr 06, 2016 11:24:55 AM INFO org.jenkinsci.plugins.jvctg.JvctsLogger doLog
FINDBUGS with pattern 
Apr 06, 2016 11:24:55 AM INFO org.jenkinsci.plugins.jvctg.JvctsLogger doLog
JSHINT with pattern 
Apr 06, 2016 11:24:55 AM INFO org.jenkinsci.plugins.jvctg.JvctsLogger doLog
PMD with pattern 
Apr 06, 2016 11:24:55 AM INFO org.jenkinsci.plugins.jvctg.JvctsLogger doLog
CPPCHECK with pattern 
Apr 06, 2016 11:24:55 AM INFO org.jenkinsci.plugins.jvctg.JvctsLogger doLog
RESHARPER with pattern 
Apr 06, 2016 11:24:55 AM INFO org.jenkinsci.plugins.jvctg.JvctsLogger doLog
FLAKE8 with pattern pylint.out
Apr 06, 2016 11:24:55 AM INFO org.jenkinsci.plugins.jvctg.JvctsLogger doLog
CPPLINT with pattern 
Apr 06, 2016 11:24:55 AM INFO org.jenkinsci.plugins.jvctg.JvctsLogger doLog
XMLLINT with pattern 
Apr 06, 2016 11:24:55 AM INFO org.jenkinsci.plugins.jvctg.JvctsLogger doLog
PERLCRITIC with pattern 
Apr 06, 2016 11:24:55 AM INFO org.jenkinsci.plugins.jvctg.JvctsLogger doLog
Workspace: /var/lib/jenkins/jobs/hulk-status-comment/workspace
Apr 06, 2016 11:24:55 AM INFO org.jenkinsci.plugins.jvctg.JvctsLogger doLog
Using username/password: d.../*********
Apr 06, 2016 11:24:55 AM INFO org.jenkinsci.plugins.jvctg.JvctsLogger doLog
Will comment PR goibibo/hulk/21 on https://api.github.com/
Apr 06, 2016 11:25:00 AM INFO se.bjurr.violations.comments.lib.CommentsCreator 
0 violations.
Apr 06, 2016 11:25:02 AM INFO se.bjurr.violations.comments.lib.CommentsCreator createComments
0 comments found.
Apr 06, 2016 11:25:02 AM INFO se.bjurr.violations.comments.lib.CommentsCreator createComments
0 comments found from CommentsCreator, asking GitHubCommentsProvider to remove them.
Apr 06, 2016 11:25:02 AM INFO se.bjurr.violations.comments.lib.CommentsCreator createSingleFileComments
Asking GitHubCommentsProvider to comment:
Apr 06, 2016 11:25:02 AM INFO se.bjurr.violations.comments.lib.CommentsCreator createCommentWithAllSingleFileComments
Asking GitHubCommentsProvider to create comment with all single file comments.

From the job configure options, I've written pylint.out as my pattern for FLAKE8. The file is being generated on the workspace main directory. i.e. I can see it when I select 'workspace' from the right menu in jenkins without going into a sub-folder.

Any ideas what I could be missing?

@tomasbjerre
Copy link
Owner

Do you have a single Jenkins master setup or do you also have slaves? Are the slaves remote or on the same machine?

@tomasbjerre
Copy link
Owner

And you are using violation-comments-to-github-plugin 1.6?

@abrahamvarricatt
Copy link
Author

this is a single jenkins machine running inside virtualbox. (it was setup via vagrant). OS is ubuntu 14.04 LTS 64-bit.

Jenkins version is : 1.655
Violation Comments to GitHub Plugin: 1.6

@tomasbjerre
Copy link
Owner

Do you find the file when executing this?
find /var/lib/jenkins/jobs/hulk-status-comment/workspace | grep pylint.out

@abrahamvarricatt
Copy link
Author

Just ran the command on my terminal,

vagrant@vagrant-ubuntu-trusty-64:~$ find /var/lib/jenkins/jobs/hulk-status-comment/workspace | grep pylint.out
/var/lib/jenkins/jobs/hulk-status-comment/workspace/pylint.out
vagrant@vagrant-ubuntu-trusty-64:~$ vim /var/lib/jenkins/jobs/hulk-status-comment/workspace/pylint.out
vagrant@vagrant-ubuntu-trusty-64:~$ file /var/lib/jenkins/jobs/hulk-status-comment/workspace/pylint.out
/var/lib/jenkins/jobs/hulk-status-comment/workspace/pylint.out: ASCII text
vagrant@vagrant-ubuntu-trusty-64:~$ 

Looks like the file's there.

@abrahamvarricatt
Copy link
Author

http://pastebin.com/8d9aYSeS

the contents of pylint.out

@tomasbjerre
Copy link
Owner

Change pylint.out in Jenkins config to .*/pylint.out$

@abrahamvarricatt
Copy link
Author

That .. that WORKED!!! 👍 💯

Thank you! I'm finally getting violation comments on my pull request!! :)

@tomasbjerre
Copy link
Owner

Nice =) I will update the documentation here and add some logging to ease troubleshooting this kind of stuff.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants