Code Monkey home page Code Monkey logo

gerrit-check's Introduction

gerrit-check -- static code analysis to Gerrit comments

TLDR: Turn cpplint / cppcheck / flake8 messages to Gerrit comments

Many projects use Gerrit for code-reviews and in addition use static code analysis tools to report about the quality of the code in review. For example, Jenkins comes with a nice integration of Gerrit, there is no suitable way to generate line-by-line annotations of the output of static code analysis tools for Gerrit.

This project allows you to transform the output of the tools: cppcheck, cpplint and flake8 into line by line comments in Gerrit.

Installation

This is as easy as:

sudo pip install gerrit-check

Usage

The typical usage for this project is to use in conjunction with a continuous integration server that runs for example pre-commit checks on a particular Gerrit change set.

gerrit-check -g gerrit.some.company.com \
    -t cpplint \
    --user jenkins \
    --commit ${GIT_HASH}

This will run cpplint on the modified files and lines identified by the GIT_HASH and submit a review on this patch to the Gerrit instance identified in the arguments.

If access to the Gerrit server is not directly possible, the -l option will force the output to be written to stdout so that it can be saved and post-processed.

In a similar way to the above described simplication the script could be used as follows:

gerrit-check -t cpplint --commit ${GIT_HASH} \
    | ssh [email protected] gerrit review ${GIT_HASH} --json

License

Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with the License. A copy of the License is located at: http://aws.amazon.com/apache2.0/

or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

gerrit-check's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

gerrit-check's Issues

Issue when using gerrit-check on ubuntu

I have this error when running the gerrit-check command:
Traceback (most recent call last): File "/usr/local/bin/gerrit-check", line 9, in <module> load_entry_point('gerrit-check==0.1.1', 'console_scripts', 'gerrit-check')() File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 351, in load_entry_point return get_distribution(dist).load_entry_point(group, name) File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 2363, in load_entry_point return ep.load() File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 2088, in load entry = __import__(self.module_name, globals(),globals(), ['__name__']) File "/usr/local/lib/python2.7/dist-packages/gerritcheck/check.py", line 18, in <module> from flake8.engine import get_style_guide ImportError: No module named engine

I installed gerrit-check using pip.

Python version 2.7.6
Ubuntu 14.04.5 LTS

I have the same error when installing it on windows.

Make check options configurable

There should be an easy way, e.g. via an external file, to configure the options / command line arguments passed to the individual checkers.

False positives on cppcheck - struct member unused

Using gerrit-check, I get frequent false positives about struct members being unused, even though they are clearly being used in .cpp implementation files, and checking those files directly will not find an issue.
It turns out that the way check.py includes header files for passing to cppcheck is wrong.
In fact this is confirmed on http://stackoverflow.com/questions/36825903/cppcheck-claims-that-a-field-is-not-used-while-it-is-in-another-file

Header files should not be explicitly checked, but are implicitly checked.
Therefore check.py, line 28 should be changed to not include .h and .hpp files.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.