Getting flake8 most critical errors on big python codebase

Question:

Given a large Python 3.6 codebase deployed in GitLab with lots of "minor" violations with flake8 (e.g. stylistic violations), I would like to first find the most serious violations (e.g. variable may be undefined, name not found…). The idea is to avoid being overwhelmed with thousands of violations reported as this tool will be introduced for the first time, and to first solve the most important issues, in order to "softly" adjust the code to be compliant. If more appropriate, other code analysis tools than flake8 could be used too.

Would you recommend ways to do this? I was thinking GitLab CI/CD pipeline may be a way, but I ignore how to configure it to achieve the above, or even what tools would be most appropriate. Thank you!

Asked By: GabCaz

||

Answers:

After researching, it seems there is no classification by seriousness of errors that comes out of the box in flake8, although other tools may have it. The solution I chose is simply to phase in static code analysis by explicitly listing flake8 violations that would be good "first candidates" (I chose F631,F704,F823,B002,B004,B006,B015,B018,B025)

    - python --version
    - pip install flake8
    - pip install flake8-bugbear
    - flake8 --version
    - flake8 --select F631,F704,F823,B002,B004,B006,B015,B018,B025 
Answered By: GabCaz
Categories: questions Tags: , , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.