Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set a pylint score threshold?

I'd like to extract my pylint rating and set a threshold. Let me explain, for example, if the score is under 5, I want exit 1; And if my code is rated higher than 5, I want exit 0 and continue my Jenkins procedure.

like image 712
Axel Bayle Avatar asked Jun 20 '18 09:06

Axel Bayle


People also ask

How does pylint calculate score?

The score is calculated using Pylint version 2.4. 3 To calculate the coding convention score, we will use the standard coding convention score calculated by Pylint. The formula for this score is as follows: 10.0 - ((float(5 * Frequency of convention errors) / Number of statement) * 10).

What is good pylint score?

In python, the most consensual writing style is defined by the PEP-8 standard, which the popular pylint package enforces. It comes with a handy metric, the Pylint score: you get a 10/10 for perfectly conforming to the standard, less it you stray from it.

What standard does pylint use?

Pylint is a Python tool that checks a module for coding standards. According to the TurboGears project coding guidelines, PEP8 is the standard and pylint is a good mechanical test to help us in attaining that goal.


1 Answers

Since pylint 2.5.0 there is a new argument called --fail-under that resolves this question without needing external tools or scripts.

In this example, pylint will exit with error when score is under 8:

pylint --fail-under=8 python_code.py
like image 146
Gooseman Avatar answered Oct 15 '22 09:10

Gooseman