Get static code analyzer messages only from 'git diff'?
In our build system (with sources under
git version control), I’d like to get the static code analyzer (
pylint, in this case) messages for every build. And I want them incremental: in the new build report, only the messages introduced by new commits are shown.
I can easily get the ‘old’ and ‘new’ commits. Then, the general path is to run the analyzer on the ‘new’ commit, and then, for each source code line with a message, find whether that line is new/modified, or if it is intact from the ‘old’ commit. Then, print only messages from new/modified lines.
Is there a simpler way of achieving this goal for
pylint? Or is there an existing implementation of something similar?
One Solution collect form web for “Get static code analyzer messages only from 'git diff'?”
You can get list of files changed between commits and pass it to pylint then. With github pullrequest workflow it looks like this:
git --no-pager diff --name-only FETCH_HEAD $(git merge-base FETCH_HEAD master) | grep .py | xargs pylint