Integrating static code analysis tools (FindBugs / PMD / Checkstyle, or Sonar) with Code Review label of Gerrit?

604 views
Skip to first unread message

Sigmund Lee

unread,
Dec 17, 2014, 4:35:45 AM12/17/14
to repo-d...@googlegroups.com
Hi all,

I am curious how can I integrate static code analysis tools as participant of Code Review label, is there any open sources solution for that?


Appreciated.

--
Sig

Luca Milanesio

unread,
Dec 17, 2014, 4:41:42 AM12/17/14
to Sigmund Lee, repo-d...@googlegroups.com
Typical scenario is:
- Jenkins CI
- FindBugs / PMD / Checkstyle / Sonar Jenkins Plugins
- Gerrit Trigger Plugin

workflow is:

- New Change (or patch-set) created
- Gerrit Trigger Plugin triggers Jenkins build
- Jenkins build executes the static analysis tool
- Jenkins build result and relevant links are put into Gerrit as review score + comments

Luca.

--
--
To unsubscribe, email repo-discuss...@googlegroups.com
More info at http://groups.google.com/group/repo-discuss?hl=en

---
You received this message because you are subscribed to the Google Groups "Repo and Gerrit Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to repo-discuss...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Sigmund Lee

unread,
Dec 17, 2014, 5:21:05 AM12/17/14
to Luca Milanesio, repo-d...@googlegroups.com
Hi Lica,

Thank you for prompt response.

Currently I am using Jenkins and it's Gerrit Trigger Plugin for Verified label of new created patchsets. So I can also take advantage of  FindBugs / PMD / Checkstyle / Sonar Jenkins Plugins, and grant Code Review label privilege to jenkins user of Gerrit, to achieve what I expected?

--
Sig

Luca Milanesio

unread,
Dec 17, 2014, 5:24:35 AM12/17/14
to Sigmund Lee, repo-d...@googlegroups.com
Yes, that’s the idea.

One suggestion: the “Code-Review” label is typically used for actual people looking at the code, not for robots.
You could define an extra review label called “Static-Analysis” and set that score from your Jenkins job through the Gerrit Trigger plugin.

For adding review labels see:

HTH.

Luca.

Bertram Karch

unread,
Dec 17, 2014, 1:19:03 PM12/17/14
to repo-d...@googlegroups.com, wua...@gmail.com
Hi Sigmund,

you can take a look at sputnik, https://github.com/TouK/sputnik.
This tool can be called in jenkins job and creates inline comments on the files, and only on these,  of the change.

Regards,
Bertram

Sigmund Lee

unread,
Dec 17, 2014, 9:22:09 PM12/17/14
to Bertram Karch, Luca Milanesio, repo-d...@googlegroups.com
Hi Luca & Bertram,

Many thanks!

About the tips and tools you mentioned, I will try it out and let you know any questions along the way.


Regards,
Sig

Jan Kundrát

unread,
Dec 18, 2014, 11:24:29 AM12/18/14
to repo-d...@googlegroups.com
On Wednesday, 17 December 2014 19:19:03 CEST, Bertram Karch wrote:
> you can take a look at sputnik, https://github.com/TouK/sputnik.
> This tool can be called in jenkins job and creates inline comments on the
> files, and only on these, of the change.

Is it smart enough to only consider changed lines as opposed to changed
files?

I suspect this is a non-trivial problem, though, because even though a
particular line didn't change, a new error might well appear on it due to
changes in other locations.

With kind regards,
Jan

--
Trojitá, a fast Qt IMAP e-mail client -- http://trojita.flaska.net/
Reply all
Reply to author
Forward
0 new messages