pylint to CodeClimate converter

Gitlab’s Code Quality documentation is all over the place and using the CodeClimate docker images seems to make things more complicated than it needs to be. The Code Climate Pylint Engine repository (which is what the image uses) gave me a useful starting point but it puts out list of JSON dicts with each issue null-terminated separated (I’m not sure why) and doesn’t give a fingerprint.

As specified in the Implementing a custom tool section of the docs Gitlab only needs a small subset of the full specification of the codeclimate fields: description, fingerprint, location.path, location.lines.begin.

After poking around it seems we can get a very lightweight pylint to Gitlab code quality JSON format by subclassing the pylint JSONReporter class and then overriding only the handle_message method to convert the pylint message.

You can then just dump the report to file in your Gitlab CI with python pylint-to-codeclimate.py owlbear > gl-code-quality-report.json.

You can find the code in gist: